diff --git a/pkg/controller/common/constants.go b/pkg/controller/common/constants.go index 3a55246441..ed53e76391 100644 --- a/pkg/controller/common/constants.go +++ b/pkg/controller/common/constants.go @@ -27,6 +27,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 4acb2a1f66..58aef7b276 100644 --- a/pkg/daemon/update.go +++ b/pkg/daemon/update.go @@ -830,6 +830,25 @@ func (dn *Daemon) updateOnClusterBuild(oldConfig, newConfig *mcfgv1.MachineConfi 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)