Skip to content

Commit 74df36f

Browse files
Merge pull request #5026 from isabella-janssen/ocpbugs-54463
[release-4.18] OCPBUGS-54463: Update desired config in MCN on OCL update
2 parents d0ab67e + 8943915 commit 74df36f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pkg/controller/common/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const (
4242

4343
// MasterLabel defines the label associated with master node. The master taint uses the same label as taint's key
4444
MasterLabel = "node-role.kubernetes.io/master"
45+
// WorkerLabel defines the label associated with worker node.
46+
WorkerLabel = "node-role.kubernetes.io/worker"
4547

4648
// MCNameSuffixAnnotationKey is used to keep track of the machine config name associated with a CR
4749
MCNameSuffixAnnotationKey = "machineconfiguration.openshift.io/mc-name-suffix"

pkg/daemon/update.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,25 @@ func (dn *Daemon) updateOnClusterLayering(oldConfig, newConfig *mcfgv1.MachineCo
843843
oldConfigName := oldConfig.GetName()
844844
newConfigName := newConfig.GetName()
845845

846+
// Add the desired config version to the MCN
847+
// get MCP associated with node. Note that in 4.18 and prior only default worker
848+
// & master node roles/MCPs are supported in MCN, thus the hard-coded label checks
849+
// for determining MCP association.
850+
pool := ""
851+
var ok bool
852+
if dn.node != nil {
853+
if _, ok = dn.node.Labels[ctrlcommon.MasterLabel]; ok {
854+
pool = "master"
855+
} else if _, ok = dn.node.Labels[ctrlcommon.WorkerLabel]; ok {
856+
pool = "worker"
857+
}
858+
}
859+
// update the MCN spec
860+
mcnErr := upgrademonitor.GenerateAndApplyMachineConfigNodeSpec(dn.featureGatesAccessor, pool, dn.node, dn.mcfgClient)
861+
if mcnErr != nil {
862+
return fmt.Errorf("error updating MCN spec for node %s: %w", dn.node.Name, mcnErr)
863+
}
864+
846865
oldIgnConfig, err := ctrlcommon.ParseAndConvertConfig(oldConfig.Spec.Config.Raw)
847866
if err != nil {
848867
return fmt.Errorf("parsing old Ignition config failed: %w", err)

0 commit comments

Comments
 (0)