Merge pull request #9524 from littlejawa/fix_createruntime_hook_not_called

runtime: Call CreateRuntime hooks at container creation time
This commit is contained in:
Greg Kurz 2024-04-23 13:43:36 +02:00 committed by GitHub
commit 42a79801f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -271,9 +271,18 @@ func CreateContainer(ctx context.Context, sandbox vc.VCSandbox, ociSpec specs.Sp
}
ctx = context.WithValue(ctx, vc.HypervisorPidKey{}, hid)
// Run pre-start OCI hooks.
err = EnterNetNS(sandbox.GetNetNs(), func() error {
return PreStartHooks(ctx, ociSpec, containerID, bundlePath)
// Run pre-start OCI hooks, in the runtime namespace.
if err := PreStartHooks(ctx, ociSpec, containerID, bundlePath); err != nil {
return err
}
// Run create runtime OCI hooks, in the runtime namespace.
if err := CreateRuntimeHooks(ctx, ociSpec, containerID, bundlePath); err != nil {
return err
}
return nil
})
if err != nil {
return vc.Process{}, err