Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controller: Handle snapshotter per handler #303

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
controller: Handle snapshotter per handler
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
commit a0400af28f1416f97706f50b0cfec6469349062a
27 changes: 13 additions & 14 deletions controllers/ccruntime_controller.go
Original file line number Diff line number Diff line change
@@ -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 != "" {
fidencio marked this conversation as resolved.
Show resolved Hide resolved
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...)