From a871a33b6578eb84f19c7e75fd1de27041cef7bb Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Mon, 14 Feb 2022 09:53:05 +0100 Subject: [PATCH] katautils: Run the createRuntime hooks The preStart hooks are being deprecated over the createRuntime ones. Signed-off-by: Samuel Ortiz --- src/runtime/pkg/katautils/create.go | 5 +++++ src/runtime/pkg/katautils/hook.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/runtime/pkg/katautils/create.go b/src/runtime/pkg/katautils/create.go index 541e481b4d..7ecc86301e 100644 --- a/src/runtime/pkg/katautils/create.go +++ b/src/runtime/pkg/katautils/create.go @@ -160,6 +160,11 @@ func CreateSandbox(ctx context.Context, vci vc.VC, ociSpec specs.Spec, runtimeCo return nil, vc.Process{}, err } + // Run create runtime OCI hooks, in the runtime namespace. + if err := CreateRuntimeHooks(ctx, ociSpec, containerID, bundlePath); err != nil { + return nil, vc.Process{}, err + } + sandbox, err := vci.CreateSandbox(ctx, sandboxConfig) if err != nil { return nil, vc.Process{}, err diff --git a/src/runtime/pkg/katautils/hook.go b/src/runtime/pkg/katautils/hook.go index 16c316fea9..303773e602 100644 --- a/src/runtime/pkg/katautils/hook.go +++ b/src/runtime/pkg/katautils/hook.go @@ -110,6 +110,15 @@ func runHooks(ctx context.Context, spec specs.Spec, hooks []specs.Hook, cid, bun return nil } +func CreateRuntimeHooks(ctx context.Context, spec specs.Spec, cid, bundlePath string) error { + // If no hook available, nothing needs to be done. + if spec.Hooks == nil { + return nil + } + + return runHooks(ctx, spec, spec.Hooks.CreateRuntime, cid, bundlePath, "createRuntime") +} + // PreStartHooks run the hooks before start container func PreStartHooks(ctx context.Context, spec specs.Spec, cid, bundlePath string) error { // If no hook available, nothing needs to be done.