Skip to content

Commit

Permalink
Call Prestart hook after namespaces have been set
Browse files Browse the repository at this point in the history
This simply move the call to the Prestart hooks to be made once we
receive the procReady message from the client.

This is necessary as we had to move the setns calls within nsexec in
order to be accomodate joining namespaces that only affect future
children (e.g. NEWPID).

Signed-off-by: Kenfe-Mickael Laventure <[email protected]>
  • Loading branch information
mlaventure committed Feb 22, 2016
1 parent 7c5732c commit 143787b
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions libcontainer/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,6 @@ func (p *initProcess) start() error {
p.manager.Destroy()
}
}()
if p.config.Config.Hooks != nil {
s := configs.HookState{
Version: p.container.config.Version,
ID: p.container.id,
Pid: p.pid(),
Root: p.config.Config.Rootfs,
}
for _, hook := range p.config.Config.Hooks.Prestart {
if err := hook.Run(s); err != nil {
return newSystemError(err)
}
}
}
if err := p.createNetworkInterfaces(); err != nil {
return newSystemError(err)
}
Expand All @@ -287,6 +274,20 @@ loop:
if err := p.manager.Set(p.config.Config); err != nil {
return newSystemError(err)
}
// call prestart hooks
if p.config.Config.Hooks != nil {
s := configs.HookState{
Version: p.container.config.Version,
ID: p.container.id,
Pid: p.pid(),
Root: p.config.Config.Rootfs,
}
for _, hook := range p.config.Config.Hooks.Prestart {
if err := hook.Run(s); err != nil {
return newSystemError(err)
}
}
}
// Sync with child.
if err := utils.WriteJSON(p.parentPipe, syncT{procRun}); err != nil {
return newSystemError(err)
Expand Down

0 comments on commit 143787b

Please sign in to comment.