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

Support multiple runtimeclasses in kataconfig.status.runtimeClass #344

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/v1/kataconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ type KataConfigSpec struct {

// KataConfigStatus defines the observed state of KataConfig
type KataConfigStatus struct {
// RuntimeClass is the name of the runtime class used in CRIO configuration
RuntimeClass string `json:"runtimeClass"`
// RuntimeClass is the names of the RuntimeClasses created by this controller
// +optional
RuntimeClass []string `json:"runtimeClass"`

// +optional
KataNodes KataNodesStatus `json:"kataNodes,omitempty"`
Expand Down
12 changes: 4 additions & 8 deletions controllers/openshift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ func (r *KataConfigOpenShiftReconciler) listKataPods() error {
}
for _, pod := range podList.Items {
if pod.Spec.RuntimeClassName != nil {
if *pod.Spec.RuntimeClassName == r.kataConfig.Status.RuntimeClass {
return fmt.Errorf("Existing pods using Kata Runtime found. Please delete the pods manually for KataConfig deletion to proceed")
if contains(r.kataConfig.Status.RuntimeClass, *pod.Spec.RuntimeClassName) {
return fmt.Errorf("Existing pods using \"%v\" RuntimeClass found. Please delete the pods manually for KataConfig deletion to proceed", *pod.Spec.RuntimeClassName)
}
}
}
Expand Down Expand Up @@ -751,12 +751,8 @@ func (r *KataConfigOpenShiftReconciler) createRuntimeClass(runtimeClassName stri
}
}

if r.kataConfig.Status.RuntimeClass == "" {
r.kataConfig.Status.RuntimeClass = runtimeClassName
err = r.Client.Status().Update(context.TODO(), r.kataConfig)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this change as it partly addresses https://issues.redhat.com/browse/KATA-2441.

if err != nil {
return err
}
if !contains(r.kataConfig.Status.RuntimeClass, runtimeClassName) {
r.kataConfig.Status.RuntimeClass = append(r.kataConfig.Status.RuntimeClass, runtimeClassName)
}

return nil
Expand Down