diff --git a/pkg/controller/bootimage/boot_image_controller.go b/pkg/controller/bootimage/boot_image_controller.go index 9c9eee0371..79d0390a81 100644 --- a/pkg/controller/bootimage/boot_image_controller.go +++ b/pkg/controller/bootimage/boot_image_controller.go @@ -118,8 +118,12 @@ const ( // Labels and Annotations required for determining architecture of a machineset MachineSetArchAnnotationKey = "capacity.cluster-autoscaler.kubernetes.io/labels" - ArchLabelKey = "kubernetes.io/arch=" - OSLabelKey = "machine.openshift.io/os-id" + ArchLabelKey = "kubernetes.io/arch=" + OSLabelKey = "machine.openshift.io/os-id" + OSStreamLabelKey = "machineconfiguration.openshift.io/osstream" + + // Stream currently supported by the MCO's boot image controller + SupportedOSStream = "rhel-9" // Threshold for hot loop detection HotLoopLimit = 3 diff --git a/pkg/controller/bootimage/cpms_helpers.go b/pkg/controller/bootimage/cpms_helpers.go index 59a0774e62..ac25c0f8ff 100644 --- a/pkg/controller/bootimage/cpms_helpers.go +++ b/pkg/controller/bootimage/cpms_helpers.go @@ -111,13 +111,23 @@ func (ctrl *Controller) syncControlPlaneMachineSet(controlPlaneMachineSet *machi klog.V(4).Infof("Finished syncing ControlPlaneMachineSet %q (%v)", controlPlaneMachineSet.Name, time.Since(startTime)) }() - // If the machineset has an owner reference, exit and report error. This means + // If the machineset has an owner reference, exit and log error. This means // that the machineset may be managed by another workflow and should not be reconciled. if len(controlPlaneMachineSet.GetOwnerReferences()) != 0 { - klog.Infof("ControlPlaneMachineSet %s has OwnerReference: %v, skipping boot image update", controlPlaneMachineSet.GetOwnerReferences()[0].Kind+"/"+controlPlaneMachineSet.GetOwnerReferences()[0].Name, controlPlaneMachineSet.Name) + klog.Infof("ControlPlaneMachineSet %s has OwnerReference: %v, skipping boot image update", controlPlaneMachineSet.Name, controlPlaneMachineSet.GetOwnerReferences()[0].Kind+"/"+controlPlaneMachineSet.GetOwnerReferences()[0].Name) return nil } + // Skip if the ControlPlaneMachineSet has a label designating a non default stream. If no stream label is defined, + // this is an older, pre "dual stream" ControlPlaneMachineSet and should be reconciled. + if streamLabel, ok := controlPlaneMachineSet.GetLabels()[OSStreamLabelKey]; ok { + if streamLabel != SupportedOSStream { + klog.Infof("ControlPlaneMachineSet %s has unsupported stream: %v, skipping boot image update", controlPlaneMachineSet.Name, streamLabel) + return nil + } + } + + // Skip if this is a windows ControlPlaneMachineSet. if os, ok := controlPlaneMachineSet.Spec.Template.OpenShiftMachineV1Beta1Machine.Spec.Labels[OSLabelKey]; ok { if os == "Windows" { klog.Infof("ControlPlaneMachineSet %s has a windows os label, skipping boot image update", controlPlaneMachineSet.Name) diff --git a/pkg/controller/bootimage/ms_helpers.go b/pkg/controller/bootimage/ms_helpers.go index 5b5c68f68f..0190ffbd22 100644 --- a/pkg/controller/bootimage/ms_helpers.go +++ b/pkg/controller/bootimage/ms_helpers.go @@ -111,13 +111,25 @@ func (ctrl *Controller) syncMAPIMachineSet(machineSet *machinev1beta1.MachineSet klog.V(4).Infof("Finished syncing MAPI machineset %q (%v)", machineSet.Name, time.Since(startTime)) }() - // If the machineset has an owner reference, exit and report error. This means + // If the machineset has an owner reference, exit and log error. This means // that the machineset may be managed by another workflow and should not be reconciled. if len(machineSet.GetOwnerReferences()) != 0 { - klog.Infof("machineset %s has OwnerReference: %v, skipping boot image update", machineSet.GetOwnerReferences()[0].Kind+"/"+machineSet.GetOwnerReferences()[0].Name, machineSet.Name) + klog.Infof("machineset %s has OwnerReference: %v, skipping boot image update", machineSet.Name, machineSet.GetOwnerReferences()[0].Kind+"/"+machineSet.GetOwnerReferences()[0].Name) return true, nil } + // Skip if the machineset has a label designating a non default stream. Not counted as skipped + // since the MCO intentionally excludes non-default streams. If no stream label is defined, + // this is an older, pre "dual stream" machineset and should be reconciled. + if streamLabel, ok := machineSet.GetLabels()[OSStreamLabelKey]; ok { + if streamLabel != SupportedOSStream { + klog.Infof("machineset %s has unsupported stream: %v, skipping boot image update", machineSet.Name, streamLabel) + return false, nil + } + } + + // Skip if this is a windows machineset. Not counted as skipped since the MCO + // intentionally excludes Windows machinesets. if os, ok := machineSet.Spec.Template.Labels[OSLabelKey]; ok { if os == "Windows" { klog.Infof("machineset %s has a windows os label, skipping boot image update", machineSet.Name)