Skip to content

Commit

Permalink
fix poststart error
Browse files Browse the repository at this point in the history
Signed-off-by: ningmingxiao <[email protected]>
  • Loading branch information
ningmingxiao committed Jul 15, 2024
1 parent 3778ae6 commit 307c2b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
13 changes: 0 additions & 13 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,6 @@ func (c *Container) start(process *Process) (retErr error) {

if process.Init {
c.fifo.Close()
if c.config.Hooks != nil {
s, err := c.currentOCIState()
if err != nil {
return err
}

if err := c.config.Hooks.Run(configs.Poststart, s); err != nil {
if err := ignoreTerminateErrors(parent.terminate()); err != nil {
logrus.Warn(fmt.Errorf("error running poststart hook: %w", err))
}
return err
}
}
}
return nil
}
Expand Down
10 changes: 10 additions & 0 deletions start.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -42,6 +43,15 @@ your host.`,
if notifySocket != nil {
return notifySocket.waitForContainer(container)
}
s, err := container.OCIState()
if err != nil {
return err
}
if container.Config().Hooks != nil {
if err := container.Config().Hooks.Run(configs.Poststart, s); err != nil {
return fmt.Errorf("run poststart hook %w", err)
}
}
return nil
case libcontainer.Stopped:
return errors.New("cannot start a container that has stopped")
Expand Down

0 comments on commit 307c2b6

Please sign in to comment.