Skip to content

Commit

Permalink
Merge pull request #344 from pmores/support-multiple-runtimeclasses-i…
Browse files Browse the repository at this point in the history
…n-kataconfig-status

Support multiple runtimeclasses in kataconfig.status.runtimeClass
  • Loading branch information
gkurz committed Sep 22, 2023
2 parents e8c710a + 3bdd0e7 commit a3903ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
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)
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

0 comments on commit a3903ac

Please sign in to comment.