Skip to content

OCPSTRAT-2876: Teach config operator to filter feature gate manifests by major version inclusion#459

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
JoelSpeed:major-version-fitlering
Mar 20, 2026
Merged

OCPSTRAT-2876: Teach config operator to filter feature gate manifests by major version inclusion#459
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
JoelSpeed:major-version-fitlering

Conversation

@JoelSpeed
Copy link
Contributor

This teaches the config operator to filter based on major-version, see openshift/library-go#2069 and openshift/api#2637

@coderabbitai
Copy link

coderabbitai bot commented Jan 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ce213c1-1a3c-40ca-8664-717df7e92ca5

📥 Commits

Reviewing files that changed from the base of the PR and between 437837a and 1548c55.

📒 Files selected for processing (2)
  • go.mod
  • pkg/operator/starter.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/operator/starter.go

Walkthrough

Parses the operator version with semver and adds manifest-level filtering by operator major version during getFeatureGateMappingFromDisk, skipping manifests whose release.openshift.io/major-version annotation does not include the operator's major version.

Changes

Cohort / File(s) Summary
Version-based featuregate filtering
pkg/operator/starter.go
Adds tolerant semver parsing of o.OperatorVersion; returns error on parse failure; during filepath.Walk skips manifests whose release.openshift.io/major-version annotation doesn't include the operator major version; adds excludesOperatorVersion and includesDesiredVersion helpers; adds strconv and semver imports.
Module dependency
go.mod
Moves github.com/blang/semver/v4 v4.0.0 from an indirect require to a direct require entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot requested review from benluddy and tkashem January 2, 2026 13:08
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 2, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/operator/starter.go (1)

393-406: Consider avoiding variable shadowing for clarity.

The loop variable version (string) is shadowed by the parsed variable (uint64) at line 395. This makes the error message at line 398 less helpful, as it prints the parsed number instead of the original string that failed to parse.

🔎 Proposed refactor
 func includesDesiredVersion(versions []string, operatorVersion uint64) (bool, error) {
-	for _, version := range versions {
-		version, err := strconv.ParseUint(version, 10, 64)
+	for _, versionStr := range versions {
+		version, err := strconv.ParseUint(versionStr, 10, 64)
 		if err != nil {
 			// Malformed annotation so should be excluded
-			return false, fmt.Errorf("malformed annotation: %s", version)
+			return false, fmt.Errorf("malformed annotation: %s", versionStr)
 		}
 		if version == operatorVersion {
 			return true, nil
 		}
 	}
 
 	return false, nil
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between b58d2c2 and 7e75885.

📒 Files selected for processing (1)
  • pkg/operator/starter.go
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • pkg/operator/starter.go
🔇 Additional comments (3)
pkg/operator/starter.go (3)

249-252: LGTM!

The operator version parsing uses ParseTolerant, which is appropriate for handling various version formats. Error handling is correct, and only the major version is extracted for filtering, which aligns with the feature requirements.


284-287: LGTM!

The version-based filtering is correctly implemented. Manifests that don't apply to the current operator version are appropriately skipped during the walk.


12-12: Library verification complete: github.com/blang/semver/v4 v4.0.0 is the latest stable version with no known security vulnerabilities.

The import is safe to use.

@JoelSpeed JoelSpeed changed the title Teach config operator to filter feature gate manifests by major version inclusion OCPSTRAT-2876: Teach config operator to filter feature gate manifests by major version inclusion Jan 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 30, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 30, 2026

@JoelSpeed: This pull request references OCPSTRAT-2876 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature to target the "4.22.0" version, but no target version was set.

Details

In response to this:

This teaches the config operator to filter based on major-version, see openshift/library-go#2069 and openshift/api#2637

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

return &ret.Status.OperatorStatusApplyConfiguration, nil
}

func excludesOperatorVersion(annotations map[string]string, operatorVersion uint64) bool {

Choose a reason for hiding this comment

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

Shall we use a more specific parameter name? for example operatorMajorVersion instead of operatorVersion

return !hasOperatorVersion
}

func includesDesiredVersion(versions []string, operatorVersion uint64) (bool, error) {

Choose a reason for hiding this comment

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

Shall we use a more specific parameter name? for example operatorMajorVersion instead of operatorVersion


func includesDesiredVersion(versions []string, operatorVersion uint64) (bool, error) {
for _, version := range versions {
version, err := strconv.ParseUint(version, 10, 64)

Choose a reason for hiding this comment

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

Should we consider versions prefixed with "-"? we use err to catch that case?

@JoelSpeed JoelSpeed force-pushed the major-version-fitlering branch from 7e75885 to af37eda Compare March 19, 2026 12:51
@JoelSpeed
Copy link
Contributor Author

Thank you for the review @JianLi-RH, I've pushed some changes to make use of more specific variable names, trimming the space and handling of negated versions

Do you have time to take another look through?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/operator/starter.go`:
- Around line 419-423: The code shadows the original string variable named
version by assigning ParseUint's result back into version, so on parse failure
the error prints a zero value; change the ParseUint call to store its uint64
result in a new identifier (e.g., parsedVersion) and update the error
construction to include the original string (use %q) or include the parse error;
specifically modify the strconv.ParseUint call and the subsequent fmt.Errorf in
pkg/operator/starter.go so it references parsedVersion for the numeric value and
uses the original version string in the error message to preserve the malformed
input for debugging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0185c357-d6bc-4401-a59c-6794301aef0a

📥 Commits

Reviewing files that changed from the base of the PR and between 7e75885 and af37eda.

📒 Files selected for processing (1)
  • pkg/operator/starter.go

Comment on lines +419 to +423
version, err := strconv.ParseUint(version, 10, 64)
if err != nil {
// Malformed annotation so should be excluded
return false, fmt.Errorf("malformed annotation: %d", version)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Variable shadowing loses the original string in error message.

The version variable is shadowed by the uint64 result of ParseUint. When parsing fails, the error message reports 0 instead of the malformed string, making debugging harder.

🛠️ Proposed fix
-		version, err := strconv.ParseUint(version, 10, 64)
+		parsedVersion, err := strconv.ParseUint(version, 10, 64)
 		if err != nil {
 			// Malformed annotation so should be excluded
-			return false, fmt.Errorf("malformed annotation: %d", version)
+			return false, fmt.Errorf("malformed annotation: %s", version)
 		}
-		if version == desiredVersion {
+		if parsedVersion == desiredVersion {
 			return true, nil
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
version, err := strconv.ParseUint(version, 10, 64)
if err != nil {
// Malformed annotation so should be excluded
return false, fmt.Errorf("malformed annotation: %d", version)
}
parsedVersion, err := strconv.ParseUint(version, 10, 64)
if err != nil {
// Malformed annotation so should be excluded
return false, fmt.Errorf("malformed annotation: %s", version)
}
if parsedVersion == desiredVersion {
return true, nil
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/operator/starter.go` around lines 419 - 423, The code shadows the
original string variable named version by assigning ParseUint's result back into
version, so on parse failure the error prints a zero value; change the ParseUint
call to store its uint64 result in a new identifier (e.g., parsedVersion) and
update the error construction to include the original string (use %q) or include
the parse error; specifically modify the strconv.ParseUint call and the
subsequent fmt.Errorf in pkg/operator/starter.go so it references parsedVersion
for the numeric value and uses the original version string in the error message
to preserve the malformed input for debugging.

@JoelSpeed JoelSpeed force-pushed the major-version-fitlering branch from af37eda to 437837a Compare March 19, 2026 13:17
@JoelSpeed JoelSpeed force-pushed the major-version-fitlering branch from 437837a to 1548c55 Compare March 19, 2026 13:31
@JoelSpeed
Copy link
Contributor Author

/pipeline required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 19, 2026

@JoelSpeed: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 19, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: everettraven, JoelSpeed

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [JoelSpeed,everettraven]

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

@JianLi-RH
Copy link

/verified by @JianLi-RH

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Mar 20, 2026
@openshift-ci-robot
Copy link

@JianLi-RH: This PR has been marked as verified by @JianLi-RH.

Details

In response to this:

/verified by @JianLi-RH

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@JianLi-RH
Copy link

@openshift-merge-bot openshift-merge-bot bot merged commit b3a21ba into openshift:main Mar 20, 2026
14 checks passed
@JoelSpeed JoelSpeed deleted the major-version-fitlering branch March 20, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants