Skip to content

Commit

Permalink
controller: Handle snapshotter per handler
Browse files Browse the repository at this point in the history
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:
kata-containers/kata-containers#8655.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
  • Loading branch information
fidencio committed Jan 5, 2024
1 parent 7d89970 commit 0ba092b
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions controllers/ccruntime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
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{
{
Expand Down Expand Up @@ -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...)
Expand Down

0 comments on commit 0ba092b

Please sign in to comment.