Skip to content

Commit

Permalink
Integrate poststart hooks with spec
Browse files Browse the repository at this point in the history
* Call poststart hooks after the container is started
* Tie in with spec configuration

Signed-off-by: Mrunal Patel <[email protected]>
  • Loading branch information
mrunalp committed Nov 6, 2015
1 parent bb2d3cd commit 452e8a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ func (c *linuxContainer) Start(process *Process) error {
if doInit {
c.updateState(parent)
}
if c.config.Hooks != nil {
s := configs.HookState{
Version: c.config.Version,
ID: c.id,
Pid: parent.pid(),
Root: c.config.Rootfs,
}
for _, hook := range c.config.Hooks.Poststart {
if err := hook.Run(s); err != nil {
if err := parent.terminate(); err != nil {
logrus.Warn(err)
}
return newSystemError(err)
}
}
}
return nil
}

Expand Down
8 changes: 8 additions & 0 deletions spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,14 @@ func createHooks(rspec *specs.LinuxRuntimeSpec, config *configs.Config) {
}
config.Hooks.Prestart = append(config.Hooks.Prestart, configs.NewCommandHook(cmd))
}
for _, h := range rspec.Hooks.Poststart {
cmd := configs.Command{
Path: h.Path,
Args: h.Args,
Env: h.Env,
}
config.Hooks.Poststart = append(config.Hooks.Poststart, configs.NewCommandHook(cmd))
}
for _, h := range rspec.Hooks.Poststop {
cmd := configs.Command{
Path: h.Path,
Expand Down

0 comments on commit 452e8a7

Please sign in to comment.