Skip to content

Commit b62fc8d

Browse files
committed
operator: add skew doc links
1 parent 7571581 commit b62fc8d

3 files changed

Lines changed: 37 additions & 7 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/sync.go

Lines changed: 28 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,30 @@ func (optr *Operator) getOCPVersionFromClusterVersion() string {
26272627
return fmt.Sprintf("%d.%d.%d", parsedVersion.Major(), parsedVersion.Minor(), parsedVersion.Patch())
26282628
}
26292629

2630+
// getCurrentOCPVersionFromClusterVersion extracts the current running OCP version from ClusterVersion history.
2631+
// It finds the most recent completed update in history and parses it to a clean version string.
2632+
// Returns an empty string if ClusterVersion cannot be retrieved or parsed.
2633+
func (optr *Operator) getCurrentOCPVersionFromClusterVersion() string {
2634+
clusterVersion, err := optr.clusterVersionLister.Get("version")
2635+
if err != nil {
2636+
klog.Warningf("Failed to get ClusterVersion: %v", err)
2637+
return ""
2638+
}
2639+
// History is ordered by recency (newest first); find the first completed entry.
2640+
for _, h := range clusterVersion.Status.History {
2641+
if h.State == configv1.CompletedUpdate {
2642+
parsedVersion, err := k8sversion.ParseGeneric(h.Version)
2643+
if err != nil {
2644+
klog.Warningf("Failed to parse current OCP version %q: %v", h.Version, err)
2645+
return ""
2646+
}
2647+
return fmt.Sprintf("%d.%d.%d", parsedVersion.Major(), parsedVersion.Minor(), parsedVersion.Patch())
2648+
}
2649+
}
2650+
klog.Warningf("ClusterVersion has no completed updates in history")
2651+
return ""
2652+
}
2653+
26302654
// isBareMetalOnLegacyProvisioningPath checks whether the BareMetal cluster is still using the
26312655
// legacy qcow2-based provisioning path. It does so by inspecting the provisioningOSDownloadURL
26322656
// field of the singleton Provisioning CR (metal3.io/v1alpha1).

0 commit comments

Comments
 (0)