Skip to content

Commit 39ca983

Browse files
Merge pull request #5825 from djoshy/add-skew-docs
OCPBUGS-78498: Update skew error message with doc links
2 parents 69b7af0 + 52ce5d6 commit 39ca983

4 files changed

Lines changed: 92 additions & 15 deletions

File tree

install/0000_90_machine-config_01_prometheus-rules.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ spec:
4949
severity: info
5050
annotations:
5151
summary: "Boot image skew enforcement is disabled. Scaling operations may not be successful."
52-
description: "Boot image skew enforcement mode is set to None. When scaling up, new nodes may be provisioned with older boot images that could introduce compatibility issues. Consider manually updating boot images to match the cluster version. Please refer to docs at [TODO-INSERTLINK] for additional details."
52+
description: "Boot image skew enforcement mode is set to None. When scaling up, new nodes may be provisioned with older boot images that could introduce compatibility issues. Consider manually updating boot images to match the cluster version. Please refer to docs at https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/machine_configuration/mco-update-boot-skew-mgmt for additional details."
5353
---
5454
apiVersion: monitoring.coreos.com/v1
5555
kind: PrometheusRule

pkg/operator/status.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,14 @@ func (optr *Operator) checkBootImageSkewUpgradeableGuard() (bool, string, error)
692692
}
693693

694694
if skewLimitExceeded {
695-
// TODO: Update error message; tracked in https://issues.redhat.com/browse/MCO-2034
696-
return true, fmt.Sprintf("Upgrades have been disabled because %s. To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]", skewLimitExceededMessage), nil
695+
docsVersion := "latest"
696+
if ocpVersion := optr.getCurrentOCPVersionFromClusterVersion(); ocpVersion != "" {
697+
if parts := strings.SplitN(ocpVersion, ".", 3); len(parts) >= 2 {
698+
docsVersion = parts[0] + "." + parts[1]
699+
}
700+
}
701+
docsURL := fmt.Sprintf("https://docs.redhat.com/en/documentation/openshift_container_platform/%s/html/machine_configuration/mco-update-boot-skew-mgmt", docsVersion)
702+
return true, fmt.Sprintf("Upgrades have been disabled because %s. To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at %s", skewLimitExceededMessage, docsURL), nil
697703
}
698704

699705
return false, "", nil

pkg/operator/status_test.go

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
797797
mcop *opv1.MachineConfiguration
798798
mcopNotFound bool
799799
mcopGetError error
800+
clusterVersion *configv1.ClusterVersion
800801
expectUpgradeBlock bool
801802
expectMessage string
802803
expectError bool
@@ -944,6 +945,9 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
944945
{
945946
name: "mode is Automatic with OCP version below limit",
946947
featureGateEnabled: true,
948+
// History spans 4.12 (install) through 4.22 (current upgrade in progress),
949+
// reflecting a cluster that never updated its boot images across many upgrades.
950+
clusterVersion: buildClusterVersionWithMultipleHistory("4.22.0", "4.21.0", "4.20.0", "4.19.0", "4.18.0", "4.17.0", "4.16.0", "4.15.0", "4.14.0", "4.13.0", "4.12.0"),
947951
mcop: &opv1.MachineConfiguration{
948952
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
949953
Status: opv1.MachineConfigurationStatus{
@@ -962,7 +966,32 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
962966
},
963967
},
964968
expectUpgradeBlock: true,
965-
expectMessage: "Upgrades have been disabled because the cluster is using OCP boot image version 4.12.0, which is below the minimum required version " + ctrlcommon.OCPVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]",
969+
expectMessage: "Upgrades have been disabled because the cluster is using OCP boot image version 4.12.0, which is below the minimum required version " + ctrlcommon.OCPVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/4.22/html/machine_configuration/mco-update-boot-skew-mgmt",
970+
expectError: false,
971+
},
972+
{
973+
name: "mode is Automatic with OCP version below limit and no ClusterVersion",
974+
featureGateEnabled: true,
975+
// No clusterVersion set — getCurrentOCPVersionFromClusterVersion returns "", docs URL falls back to "latest".
976+
mcop: &opv1.MachineConfiguration{
977+
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
978+
Status: opv1.MachineConfigurationStatus{
979+
Conditions: []metav1.Condition{
980+
{
981+
Type: opv1.MachineConfigurationBootImageUpdateProgressing,
982+
Status: metav1.ConditionFalse,
983+
},
984+
},
985+
BootImageSkewEnforcementStatus: opv1.BootImageSkewEnforcementStatus{
986+
Mode: opv1.BootImageSkewEnforcementModeStatusAutomatic,
987+
Automatic: opv1.ClusterBootImageAutomatic{
988+
OCPVersion: "4.12.0",
989+
},
990+
},
991+
},
992+
},
993+
expectUpgradeBlock: true,
994+
expectMessage: "Upgrades have been disabled because the cluster is using OCP boot image version 4.12.0, which is below the minimum required version " + ctrlcommon.OCPVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/machine_configuration/mco-update-boot-skew-mgmt",
966995
expectError: false,
967996
},
968997
// OCP version tests in manual mode
@@ -988,6 +1017,9 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
9881017
{
9891018
name: "mode is Manual with OCP version below limit",
9901019
featureGateEnabled: true,
1020+
// History spans 4.10 (install) through 4.22 (current upgrade in progress),
1021+
// reflecting a cluster that never updated its boot images across many upgrades.
1022+
clusterVersion: buildClusterVersionWithMultipleHistory("4.22.0", "4.21.0", "4.20.0", "4.19.0", "4.18.0", "4.17.0", "4.16.0", "4.15.0", "4.14.0", "4.13.0", "4.12.0", "4.11.0", "4.10.0"),
9911023
mcop: &opv1.MachineConfiguration{
9921024
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
9931025
Status: opv1.MachineConfigurationStatus{
@@ -1001,7 +1033,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
10011033
},
10021034
},
10031035
expectUpgradeBlock: true,
1004-
expectMessage: "Upgrades have been disabled because the cluster is using OCP boot image version 4.10.0, which is below the minimum required version " + ctrlcommon.OCPVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]",
1036+
expectMessage: "Upgrades have been disabled because the cluster is using OCP boot image version 4.10.0, which is below the minimum required version " + ctrlcommon.OCPVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/4.22/html/machine_configuration/mco-update-boot-skew-mgmt",
10051037
expectError: false,
10061038
},
10071039
{
@@ -1056,6 +1088,8 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
10561088
{
10571089
name: "mode is Automatic with modern RHCOS version below limit",
10581090
featureGateEnabled: true,
1091+
// RHEL 9 boot images were introduced in 4.13; history spans from there to 4.22.
1092+
clusterVersion: buildClusterVersionWithMultipleHistory("4.22.0", "4.21.0", "4.20.0", "4.19.0", "4.18.0", "4.17.0", "4.16.0", "4.15.0", "4.14.0", "4.13.0"),
10591093
mcop: &opv1.MachineConfiguration{
10601094
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
10611095
Status: opv1.MachineConfigurationStatus{
@@ -1074,7 +1108,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
10741108
},
10751109
},
10761110
expectUpgradeBlock: true,
1077-
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 9.0.20251023-0(RHEL version: 9.0), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]",
1111+
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 9.0.20251023-0(RHEL version: 9.0), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/4.22/html/machine_configuration/mco-update-boot-skew-mgmt",
10781112
expectError: false,
10791113
},
10801114
{
@@ -1104,6 +1138,8 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
11041138
{
11051139
name: "mode is Automatic with legacy RHCOS version below limit",
11061140
featureGateEnabled: true,
1141+
// Legacy RHEL 8 (411.x) boot images originate from 4.11; history spans from there to 4.22.
1142+
clusterVersion: buildClusterVersionWithMultipleHistory("4.22.0", "4.21.0", "4.20.0", "4.19.0", "4.18.0", "4.17.0", "4.16.0", "4.15.0", "4.14.0", "4.13.0", "4.12.0", "4.11.0"),
11071143
mcop: &opv1.MachineConfiguration{
11081144
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
11091145
Status: opv1.MachineConfigurationStatus{
@@ -1122,7 +1158,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
11221158
},
11231159
},
11241160
expectUpgradeBlock: true,
1125-
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 411.86.202308081056-0(RHEL version: 8.6), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]",
1161+
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 411.86.202308081056-0(RHEL version: 8.6), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/4.22/html/machine_configuration/mco-update-boot-skew-mgmt",
11261162
expectError: false,
11271163
},
11281164

@@ -1173,6 +1209,8 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
11731209
{
11741210
name: "mode is Manual with modern RHCOS version below limit",
11751211
featureGateEnabled: true,
1212+
// RHEL 9 boot images were introduced in 4.13; history spans from there to 4.22.
1213+
clusterVersion: buildClusterVersionWithMultipleHistory("4.22.0", "4.21.0", "4.20.0", "4.19.0", "4.18.0", "4.17.0", "4.16.0", "4.15.0", "4.14.0", "4.13.0"),
11761214
mcop: &opv1.MachineConfiguration{
11771215
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
11781216
Status: opv1.MachineConfigurationStatus{
@@ -1186,7 +1224,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
11861224
},
11871225
},
11881226
expectUpgradeBlock: true,
1189-
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 9.1.20251023-0(RHEL version: 9.1), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]",
1227+
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 9.1.20251023-0(RHEL version: 9.1), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/4.22/html/machine_configuration/mco-update-boot-skew-mgmt",
11901228
expectError: false,
11911229
},
11921230
{
@@ -1211,6 +1249,8 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
12111249
{
12121250
name: "mode is Manual with legacy RHCOS version below limit",
12131251
featureGateEnabled: true,
1252+
// Legacy RHEL 8 (411.x) boot images originate from 4.11; history spans from there to 4.22.
1253+
clusterVersion: buildClusterVersionWithMultipleHistory("4.22.0", "4.21.0", "4.20.0", "4.19.0", "4.18.0", "4.17.0", "4.16.0", "4.15.0", "4.14.0", "4.13.0", "4.12.0", "4.11.0"),
12141254
mcop: &opv1.MachineConfiguration{
12151255
ObjectMeta: metav1.ObjectMeta{Name: ctrlcommon.MCOOperatorKnobsObjectName},
12161256
Status: opv1.MachineConfigurationStatus{
@@ -1224,7 +1264,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
12241264
},
12251265
},
12261266
expectUpgradeBlock: true,
1227-
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 411.86.202308081056-0(RHEL version: 8.6), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images following the documentation at [TODO: insert link], or disable boot image skew enforcement at [TODO: insert link]",
1267+
expectMessage: "Upgrades have been disabled because the cluster is using RHCOS boot image version 411.86.202308081056-0(RHEL version: 8.6), which is below the minimum required RHEL version " + ctrlcommon.RHCOSVersionBootImageSkewLimit + ". To enable upgrades, please update your boot images or disable boot image skew enforcement by following the documentation at https://docs.redhat.com/en/documentation/openshift_container_platform/4.22/html/machine_configuration/mco-update-boot-skew-mgmt",
12281268
expectError: false,
12291269
},
12301270
{
@@ -1264,9 +1304,17 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) {
12641304
}
12651305
mcopLister := mcoplistersv1.NewMachineConfigurationLister(mcopIndexer)
12661306

1307+
// Set up clusterVersionLister
1308+
clusterVersionIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
1309+
if tc.clusterVersion != nil {
1310+
clusterVersionIndexer.Add(tc.clusterVersion)
1311+
}
1312+
clusterVersionLister := configlistersv1.NewClusterVersionLister(clusterVersionIndexer)
1313+
12671314
optr := &Operator{
1268-
fgHandler: fgHandler,
1269-
mcopLister: mcopLister,
1315+
fgHandler: fgHandler,
1316+
mcopLister: mcopLister,
1317+
clusterVersionLister: clusterVersionLister,
12701318
}
12711319

12721320
upgradeBlock, message, err := optr.checkBootImageSkewUpgradeableGuard()

pkg/operator/sync.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,7 +2550,7 @@ func (optr *Operator) syncBootImageSkewEnforcementStatus(mcop *opv1.MachineConfi
25502550
}
25512551

25522552
// Grab install time OCP version
2553-
ocpVersionAtInstall := optr.getOCPVersionFromClusterVersion()
2553+
ocpVersionAtInstall := optr.getOCPInstallVersionFromClusterVersion()
25542554

25552555
// Spec override takes priority over all platform defaults.
25562556
if mcop.Spec.BootImageSkewEnforcement != (opv1.BootImageSkewEnforcementConfig{}) {
@@ -2591,10 +2591,10 @@ func (optr *Operator) syncBootImageSkewEnforcementStatus(mcop *opv1.MachineConfi
25912591
newMachineConfigurationStatus.BootImageSkewEnforcementStatus = apihelpers.GetSkewEnforcementStatusManualWithOCPVersion(ocpVersionAtInstall)
25922592
}
25932593

2594-
// getOCPVersionFromClusterVersion extracts the OCP version from ClusterVersion history.
2595-
// It finds the last completed update in history (install version) and parses it to a clean version string.
2594+
// getOCPInstallVersionFromClusterVersion extracts the original install version from ClusterVersion history.
2595+
// It finds the oldest completed update in history and parses it to a clean version string.
25962596
// Returns an empty string if ClusterVersion cannot be retrieved or parsed.
2597-
func (optr *Operator) getOCPVersionFromClusterVersion() string {
2597+
func (optr *Operator) getOCPInstallVersionFromClusterVersion() string {
25982598
clusterVersion, err := optr.clusterVersionLister.Get("version")
25992599
if err != nil {
26002600
klog.Warningf("Failed to get ClusterVersion: %v, skipping boot image skew enforcement configuration", err)
@@ -2627,6 +2627,29 @@ func (optr *Operator) getOCPVersionFromClusterVersion() string {
26272627
return fmt.Sprintf("%d.%d.%d", parsedVersion.Major(), parsedVersion.Minor(), parsedVersion.Patch())
26282628
}
26292629

2630+
// getCurrentOCPVersionFromClusterVersion extracts the latest OCP version from ClusterVersion history.
2631+
// It takes the most recent history entry regardless of update state, so that docs links always
2632+
// point to the newest version even during an in-progress upgrade.
2633+
// Returns an empty string if ClusterVersion cannot be retrieved or parsed.
2634+
func (optr *Operator) getCurrentOCPVersionFromClusterVersion() string {
2635+
clusterVersion, err := optr.clusterVersionLister.Get("version")
2636+
if err != nil {
2637+
klog.Warningf("Failed to get ClusterVersion: %v", err)
2638+
return ""
2639+
}
2640+
if len(clusterVersion.Status.History) == 0 {
2641+
klog.Warningf("ClusterVersion has no history")
2642+
return ""
2643+
}
2644+
latest := clusterVersion.Status.History[0].Version
2645+
parsedVersion, err := k8sversion.ParseGeneric(latest)
2646+
if err != nil {
2647+
klog.Warningf("Failed to parse current OCP version %q: %v", latest, err)
2648+
return ""
2649+
}
2650+
return fmt.Sprintf("%d.%d.%d", parsedVersion.Major(), parsedVersion.Minor(), parsedVersion.Patch())
2651+
}
2652+
26302653
// isBareMetalOnLegacyProvisioningPath checks whether the BareMetal cluster is still using the
26312654
// legacy qcow2-based provisioning path. It does so by inspecting the provisioningOSDownloadURL
26322655
// field of the singleton Provisioning CR (metal3.io/v1alpha1).

0 commit comments

Comments
 (0)