diff --git a/pkg/controller/common/constants.go b/pkg/controller/common/constants.go index 61d786b349..cf7208f38c 100644 --- a/pkg/controller/common/constants.go +++ b/pkg/controller/common/constants.go @@ -42,6 +42,8 @@ const ( // MasterLabel defines the label associated with master node. The master taint uses the same label as taint's key MasterLabel = "node-role.kubernetes.io/master" + // WorkerLabel defines the label associated with worker node. + WorkerLabel = "node-role.kubernetes.io/worker" // MCNameSuffixAnnotationKey is used to keep track of the machine config name associated with a CR MCNameSuffixAnnotationKey = "machineconfiguration.openshift.io/mc-name-suffix" diff --git a/pkg/daemon/update.go b/pkg/daemon/update.go index c0dbf554b3..7c8e9181b5 100644 --- a/pkg/daemon/update.go +++ b/pkg/daemon/update.go @@ -843,6 +843,25 @@ func (dn *Daemon) updateOnClusterLayering(oldConfig, newConfig *mcfgv1.MachineCo oldConfigName := oldConfig.GetName() newConfigName := newConfig.GetName() + // Add the desired config version to the MCN + // get MCP associated with node. Note that in 4.18 and prior only default worker + // & master node roles/MCPs are supported in MCN, thus the hard-coded label checks + // for determining MCP association. + pool := "" + var ok bool + if dn.node != nil { + if _, ok = dn.node.Labels[ctrlcommon.MasterLabel]; ok { + pool = "master" + } else if _, ok = dn.node.Labels[ctrlcommon.WorkerLabel]; ok { + pool = "worker" + } + } + // update the MCN spec + mcnErr := upgrademonitor.GenerateAndApplyMachineConfigNodeSpec(dn.featureGatesAccessor, pool, dn.node, dn.mcfgClient) + if mcnErr != nil { + return fmt.Errorf("error updating MCN spec for node %s: %w", dn.node.Name, mcnErr) + } + oldIgnConfig, err := ctrlcommon.ParseAndConvertConfig(oldConfig.Spec.Config.Raw) if err != nil { return fmt.Errorf("parsing old Ignition config failed: %w", err)