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 6ffc50a
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[configs.Poststart].RunHooks(s); err != nil {

Check failure on line 51 in start.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: container.Config().Hooks[configs.Poststart].RunHooks is deprecated: use (Hooks).Run instead. (staticcheck)
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 6ffc50a

Please sign in to comment.