Skip to content

Commit 6ffc50a

Browse files
committed
fix poststart error
Signed-off-by: ningmingxiao <[email protected]>
1 parent 3778ae6 commit 6ffc50a

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

libcontainer/container_linux.go

-13
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,6 @@ func (c *Container) start(process *Process) (retErr error) {
353353

354354
if process.Init {
355355
c.fifo.Close()
356-
if c.config.Hooks != nil {
357-
s, err := c.currentOCIState()
358-
if err != nil {
359-
return err
360-
}
361-
362-
if err := c.config.Hooks.Run(configs.Poststart, s); err != nil {
363-
if err := ignoreTerminateErrors(parent.terminate()); err != nil {
364-
logrus.Warn(fmt.Errorf("error running poststart hook: %w", err))
365-
}
366-
return err
367-
}
368-
}
369356
}
370357
return nil
371358
}

start.go

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/opencontainers/runc/libcontainer"
9+
"github.com/opencontainers/runc/libcontainer/configs"
910
"github.com/urfave/cli"
1011
)
1112

@@ -42,6 +43,15 @@ your host.`,
4243
if notifySocket != nil {
4344
return notifySocket.waitForContainer(container)
4445
}
46+
s, err := container.OCIState()
47+
if err != nil {
48+
return err
49+
}
50+
if container.Config().Hooks != nil {
51+
if err := container.Config().Hooks[configs.Poststart].RunHooks(s); err != nil {
52+
return fmt.Errorf("run poststart hook %w", err)
53+
}
54+
}
4555
return nil
4656
case libcontainer.Stopped:
4757
return errors.New("cannot start a container that has stopped")

0 commit comments

Comments
 (0)