-
Notifications
You must be signed in to change notification settings - Fork 250
OKD-194: Add OKD cincinnati as the default update service for OKD #1466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ import ( | |
| const noArchitecture string = "NoArchitecture" | ||
| const noChannel string = "NoChannel" | ||
| const defaultUpdateService string = "https://api.openshift.com/api/upgrades_info/v1/graph" | ||
| const defaultOKDUpdateService string = "https://updates.okd.io/api/updates/graph" | ||
|
|
||
| // syncAvailableUpdates attempts to retrieve the latest updates and update the status of the ClusterVersion | ||
| // object. It will set the RetrievedUpdates condition. Updates are only checked if it has been more than | ||
|
|
@@ -48,8 +49,13 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1 | |
| updateServiceSource = "ClusterVersion spec.upstream" | ||
| } else { | ||
| usedDefaultUpdateService = true | ||
| updateService = defaultUpdateService | ||
| updateServiceSource = "the operator's default update service" | ||
| if isOKDRelease(optr.release.Version) { | ||
| updateService = defaultOKDUpdateService | ||
| updateServiceSource = "the operator's default OKD update service" | ||
| } else { | ||
| updateService = defaultUpdateService | ||
| updateServiceSource = "the operator's default update service" | ||
| } | ||
| } | ||
|
|
||
| channel := config.Spec.Channel | ||
|
|
@@ -85,7 +91,7 @@ func (optr *Operator) syncAvailableUpdates(ctx context.Context, config *configv1 | |
| } else if !optrAvailableUpdates.RecentlyAttempted(optr.minimumUpdateCheckInterval) { | ||
| klog.V(2).Infof("Retrieving available updates again, because more than %s has elapsed since last attempt at %s", optr.minimumUpdateCheckInterval, optrAvailableUpdates.LastAttempt.Format(time.RFC3339)) | ||
| preserveCacheOnFailure = true | ||
| } else if updateService == optrAvailableUpdates.UpdateService || (updateService == defaultUpdateService && optrAvailableUpdates.UpdateService == "") { | ||
| } else if updateService == optrAvailableUpdates.UpdateService || (usedDefaultUpdateService && optrAvailableUpdates.UpdateService == "") { | ||
| needsConditionalUpdateEval := false | ||
| preserveCacheOnFailure = true | ||
| for _, conditionalUpdate := range optrAvailableUpdates.ConditionalUpdates { | ||
|
|
@@ -452,6 +458,25 @@ func loadRiskVersions(conditionalUpdates []configv1.ConditionalUpdate) map[strin | |
| return riskVersions | ||
| } | ||
|
|
||
| // isOKDRelease returns true when the given release version string identifies an | ||
| // OKD release. OKD releases embed an "okd" identifier in the semantic version | ||
| // pre-release segment (for example "4.19.0-0.okd-2024-01-06-084517" or | ||
| // "4.22.0-0.okd-scos-nightly-2025-..."), while OCP releases do not embed this | ||
| // identifier. It is used to select the appropriate default update service. | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| func isOKDRelease(version string) bool { | ||
| v, err := semver.Parse(version) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. along with this check i would also make sure this operator itself has been built for OKD - we pass in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With that tag in place, why check the release version at all? Can't you just switch on the tag to figure out which default URI to use?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tag was never put in place for the CVO. This was an intentional decision since we didn't want to diverge OKD CVO too much from OCP CVO, hence why the release version check is put in place |
||
| if err != nil { | ||
| klog.V(2).Infof("Unable to parse release version %q to determine whether this is an OKD cluster: %v", version, err) | ||
| return false | ||
| } | ||
| for _, pre := range v.Pre { | ||
| if strings.HasPrefix(pre.VersionStr, "okd") { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| func (optr *Operator) getDesiredArchitecture(update *configv1.Update) string { | ||
| if update != nil && len(update.Architecture) > 0 { | ||
| return string(update.Architecture) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package cvo | ||
|
|
||
| import ( | ||
| configv1 "github.com/openshift/api/config/v1" | ||
|
|
||
| "github.com/openshift/cluster-version-operator/lib/resourcemerge" | ||
| "github.com/openshift/cluster-version-operator/pkg/internal" | ||
| ) | ||
|
|
||
| const legacyOKDUpdateService = "https://amd64.origin.releases.ci.openshift.org/graph" | ||
|
|
||
| // UpdateOKDLegacyUpdateServiceCondition updates the status condition that warns about the legacy OKD update service. | ||
| func UpdateOKDLegacyUpdateServiceCondition(status *configv1.ClusterVersionStatus, upstream configv1.URL) { | ||
| if string(upstream) != legacyOKDUpdateService { | ||
| resourcemerge.RemoveOperatorStatusCondition(&status.Conditions, internal.ClusterVersionOKDLegacyUpdateService) | ||
| return | ||
| } | ||
|
|
||
| resourcemerge.SetOperatorStatusCondition(&status.Conditions, configv1.ClusterOperatorStatusCondition{ | ||
| Type: internal.ClusterVersionOKDLegacyUpdateService, | ||
| Status: configv1.ConditionTrue, | ||
| Reason: "LegacyUpstreamConfigured", | ||
| Message: "ClusterVersion spec.upstream is set to the legacy OKD update service " + legacyOKDUpdateService + ". Clear spec.upstream to use the OKD Cincinnati update service.", | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| package cvo | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
|
|
||
| "github.com/openshift/cluster-version-operator/lib/resourcemerge" | ||
| "github.com/openshift/cluster-version-operator/pkg/internal" | ||
| ) | ||
|
|
||
| func TestUpdateOKDLegacyUpdateServiceCondition(t *testing.T) { | ||
| originalTransitionTime := metav1.NewTime(time.Unix(1, 0)) | ||
| tests := []struct { | ||
| name string | ||
| upstream configv1.URL | ||
| conditions []configv1.ClusterOperatorStatusCondition | ||
| want bool | ||
| wantPreservedTransition bool | ||
| }{ | ||
| { | ||
| name: "legacy update service", | ||
| upstream: legacyOKDUpdateService, | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "custom update service", | ||
| upstream: "https://example.com/graph", | ||
| }, | ||
| { | ||
| name: "legacy URL with trailing slash does not match", | ||
| upstream: legacyOKDUpdateService + "/", | ||
| }, | ||
| { | ||
| name: "default update service", | ||
| }, | ||
| { | ||
| name: "resolved warning is removed", | ||
| upstream: "https://example.com/graph", | ||
| conditions: []configv1.ClusterOperatorStatusCondition{{ | ||
| Type: internal.ClusterVersionOKDLegacyUpdateService, | ||
| Status: configv1.ConditionTrue, | ||
| Reason: "LegacyUpstreamConfigured", | ||
| LastTransitionTime: originalTransitionTime, | ||
| }}, | ||
| }, | ||
| { | ||
| name: "unchanged warning preserves transition time", | ||
| upstream: legacyOKDUpdateService, | ||
| conditions: []configv1.ClusterOperatorStatusCondition{{ | ||
| Type: internal.ClusterVersionOKDLegacyUpdateService, | ||
| Status: configv1.ConditionTrue, | ||
| Reason: "LegacyUpstreamConfigured", | ||
| LastTransitionTime: originalTransitionTime, | ||
| }}, | ||
| want: true, | ||
| wantPreservedTransition: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| status := &configv1.ClusterVersionStatus{Conditions: tt.conditions} | ||
| UpdateOKDLegacyUpdateServiceCondition(status, tt.upstream) | ||
|
|
||
| condition := resourcemerge.FindOperatorStatusCondition(status.Conditions, internal.ClusterVersionOKDLegacyUpdateService) | ||
| if tt.want { | ||
| if condition == nil { | ||
| t.Fatal("LegacyUpdateService condition is missing") | ||
| } | ||
| if condition.Status != configv1.ConditionTrue || condition.Reason != "LegacyUpstreamConfigured" || condition.Message == "" { | ||
| t.Fatalf("unexpected LegacyUpdateService condition: %#v", condition) | ||
| } | ||
| if tt.wantPreservedTransition && condition.LastTransitionTime != originalTransitionTime { | ||
| t.Fatalf("lastTransitionTime = %v, want %v", condition.LastTransitionTime, originalTransitionTime) | ||
| } | ||
| } else if condition != nil { | ||
| t.Fatalf("unexpected LegacyUpdateService condition: %#v", condition) | ||
| } | ||
| }) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.