Skip to content

Prefer latest if no gateway from minor for active versions and all candidates - #6122

Closed
machi1990 wants to merge 1 commit into
Azure:mainfrom
machi1990:prefer-latest-if-no-gateway-from-minor-for-active-versions-and-all-candidates
Closed

Prefer latest if no gateway from minor for active versions and all candidates#6122
machi1990 wants to merge 1 commit into
Azure:mainfrom
machi1990:prefer-latest-if-no-gateway-from-minor-for-active-versions-and-all-candidates

Conversation

@machi1990

Copy link
Copy Markdown
Collaborator

What

fix: prefer latest z-stream candidate when no next-minor path exists

Why

When the next-minor channel exists but neither candidates nor active
versions are gateways, return the latest candidate instead of nil —
there is no existing next-minor path to preserve. Preferring the latest
candidate prioritizes security and bug fixes over withholding an upgrade
that cannot unlock the next minor anyway.

Testing

Testing is required for feature completion and tests should be part of the pull
request along with the feature changes.

Describe the testing provided. If you did not add tests, provide a clear
justification.

Special notes for your reviewer

Review the second commit only; the first commit comes from #6110

PR Checklist

  • PR is scoped to a single task (no mixed concerns)
  • Title follows Conventional Commits format
  • Summary explains the "Why" behind the change
  • Linked to relevant ticket/issue
  • Screenshots included (if graph/UI/metrics changes)
  • Self-reviewed the diff
  • CI/CD checks are passing (ignore Tide)
  • Draft PR used for WIP (if applicable)
  • Commit history is clean (rebased/squashed)
  • Tricky code blocks are commented
  • Specific reviewers tagged
  • All comment threads resolved before merge

If E2E tests are included:

  • E2E tests follow Principles of Good E2E Test Case Design
  • If new E2E use case is covered (via a new test or new check/verifier),
    demonstrate that the test is able to detect a defect/error and fail with
    proper error message and logs which communicates nature of the problem.

Comment on lines +583 to +591
for _, active := range activeVersions {
isGateway, err := isGatewayToNextMinor(ctx, active, cincinnatiClient, channelGroup, nextMinor)
if err != nil {
return nil, utils.TrackError(err)
}
if isGateway {
return nil, nil
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seeing it written in code, would this mean that if we somehow end up at a 4.y.z with no path to 4.y+1, then we can keep upgrading to the very latest 4.y.z that still has path to 4.y+1 because it's so new? That would be unfortunate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this mean that if we somehow end up at a 4.y.z with no path to 4.y+1

For z-stream upgrade, If we reach this branch, it is because neither of the upgrade candidates in 4.y have an upgrade path to 4.y+1.

then we can keep upgrading to the very latest 4.y.z that still has path to 4.y+1 because it's so new?

Here we know that 4.y+1 is still new and/or all 4.y active versions in the cluster plus 4.y.z+1 upgrade candidates do not have an upgrade to 4.y+1; in this case yes we continue honoring z-stream upgrade within 4.y; maintaining our priority to security & bug fixes within 4.y. We can do this as we don't have the upgrade path to 4.y+1 that we'd want to preserve

That would be unfortunate.

Yes, I don't have the data how often this happened when a new minor is released but while I was at #6110 this came up as a gap. If this at all happens without this improvement ; the following will occur.

@deads2k thoughts?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a dedicated Cincinnati “graph channel existence” client and updates control plane desired-version selection so z-stream upgrades prefer the latest candidate when there is no next-minor gateway path to preserve (across both active versions and candidates).

Changes:

  • Add internal/cincinnati.GraphClient (with unit tests + gomock) to check whether a next-minor channel/stream is published.
  • Wire GraphClient into the control plane desired-version controller and update the selection algorithm to return latest candidate when no next-minor gateway exists for either active versions or candidates.
  • Update controller unit tests to mock channel existence and cover the new z-stream behavior.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/cincinnati/graph_client.go New HTTP-based client for checking channel/stream existence in public Cincinnati APIs.
internal/cincinnati/mock_graph_client.go Generated GoMock for GraphClient.
internal/cincinnati/graph_client_test.go Unit tests for GraphClient.ChannelExists across stable/candidate/fast and nightly behaviors.
backend/pkg/controllers/upgradecontrollers/control_plane_desired_version_controller.go Inject GraphClient and adjust version-selection behavior for z-stream upgrades when no gateway exists.
backend/pkg/controllers/upgradecontrollers/control_plane_desired_version_controller_test.go Update tests to mock GraphClient.ChannelExists and validate new selection outcomes.
Files not reviewed (1)
  • internal/cincinnati/mock_graph_client.go: Generated file


func (c graphClient) channelExistsFromGraphURL(ctx context.Context, channelGroup, minor string) (bool, error) {
channel := fmt.Sprintf("%s-%s", channelGroup, minor)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api/upgrades_info/v1/graph?channel=%s", c.graphAPIBase, url.QueryEscape(channel)), nil)
Comment on lines +47 to +52
// NewGraphClient returns a GraphClient that queries the public Cincinnati APIs.
func NewGraphClient() GraphClient {
return graphClient{
graphAPIBase: "https://api.openshift.com",
nightlyAPIBase: "https://multi.ocp.releases.ci.openshift.org",
}
When the next-minor channel exists but neither candidates nor active
versions are gateways, return the latest candidate instead of nil —
there is no existing next-minor path to preserve. Preferring the latest
candidate prioritizes security and bug fixes over withholding an upgrade
that cannot unlock the next minor anyway.

Follows up Azure#6110 (comment)
Copilot AI review requested due to automatic review settings July 17, 2026 06:19
@machi1990
machi1990 force-pushed the prefer-latest-if-no-gateway-from-minor-for-active-versions-and-all-candidates branch from b528d13 to 627961c Compare July 17, 2026 06:19
@openshift-ci

openshift-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: machi1990
Once this PR has been reviewed and has the lgtm label, please assign janboll for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@machi1990

Copy link
Copy Markdown
Collaborator Author

Superseded by #6192

@machi1990 machi1990 closed this Jul 29, 2026
@machi1990
machi1990 deleted the prefer-latest-if-no-gateway-from-minor-for-active-versions-and-all-candidates branch July 29, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants