From a0400af28f1416f97706f50b0cfec6469349062a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 13 Dec 2023 15:19:11 +0100 Subject: [PATCH] controller: Handle snapshotter per handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's start properly setting a specific snapshotter per runtime handler configured for containerd. This work depends on a work done on the Kata Containers side to better support setting snapshotters per runtime handler. The PR from the Kata Containers side is: https://github.com/kata-containers/kata-containers/pull/8655. Signed-off-by: Fabiano FidĂȘncio --- controllers/ccruntime_controller.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/controllers/ccruntime_controller.go b/controllers/ccruntime_controller.go index 20164346..d418bd8a 100644 --- a/controllers/ccruntime_controller.go +++ b/controllers/ccruntime_controller.go @@ -628,20 +628,19 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv createDefaultRuntimeClass = "true" } - var runtimeClassNames []string - var snapshotter = "" + var shims []string + var snapshotter_handler_mapping []string for _, runtimeClass := range r.ccRuntime.Spec.Config.RuntimeClasses { - runtimeClassNames = append(runtimeClassNames, runtimeClass.Name) - // FIXME: This will need to be changed by the moment the kata-containers - // payload script supports setting one snapshotter per runtime handler. - // For now, for the v0.8.0 release, we're fine assuming that all the - // set snapshotters are going to be the same. - if snapshotter == "" && runtimeClass.Snapshotter != "" { - snapshotter = runtimeClass.Snapshotter + // Similarly to what's being done for the default shim, let's remove + // the "kata-" prefix from the runtime class names + shim := strings.TrimPrefix(runtimeClass.Name, "kata-") + shims = append(shims, shim) + + if runtimeClass.Snapshotter != "" { + mapping := shim + ":" + runtimeClass.Snapshotter + snapshotter_handler_mapping = append(snapshotter_handler_mapping, mapping) } } - var runtimeClasses = strings.Join(runtimeClassNames, " ") - var shims = strings.ReplaceAll(runtimeClasses, "kata-", "") var envVars = []corev1.EnvVar{ { @@ -670,11 +669,11 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv }, { Name: "SHIMS", - Value: shims, + Value: strings.Join(shims, " "), }, { - Name: "SNAPSHOTTER", - Value: snapshotter, + Name: "SNAPSHOTTER_HANDLER_MAPPING", + Value: strings.Join(snapshotter_handler_mapping, ","), }, } envVars = append(envVars, r.ccRuntime.Spec.Config.EnvironmentVariables...)