Skip to content

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

Walkthrough

Adds operator version parsing using semver and introduces version-based filtering for featuregate manifests. New helper functions evaluate whether manifests apply to the current operator version, filtering results in getFeatureGateMappingFromDisk based on operator major version annotations.

Changes

Cohort / File(s) Summary
Version-based featuregate filtering
pkg/operator/starter.go
Adds semver version parsing for operator; introduces excludesOperatorVersion and includesDesiredVersion helpers to evaluate manifest applicability; applies filtering in getFeatureGateMappingFromDisk to skip non-applicable manifests; adds strconv and blang/semver/v4 imports

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing touches
  • 📝 Generate docstrings

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
Copy link
Contributor

openshift-ci bot commented Jan 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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:

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

@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.

Comment on lines +368 to +391
func excludesOperatorVersion(annotations map[string]string, operatorVersion uint64) bool {
var versionsRaw string

for k, v := range annotations {
if k == "release.openshift.io/major-version" {
versionsRaw = v
break
}
}

if versionsRaw == "" {
return false
}

versions := strings.Split(versionsRaw, ",")

hasOperatorVersion, err := includesDesiredVersion(versions, operatorVersion)
if err != nil {
// Malformed annotation so should be excluded.
return true
}

return !hasOperatorVersion
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Trim whitespace when parsing version list.

The version strings are split by comma but not trimmed of whitespace. If an annotation contains spaces (e.g., "4, 5"), the parsing in includesDesiredVersion will fail, causing the manifest to be incorrectly excluded.

🔎 Proposed fix to trim whitespace
 	versions := strings.Split(versionsRaw, ",")
+	for i := range versions {
+		versions[i] = strings.TrimSpace(versions[i])
+	}
 
 	hasOperatorVersion, err := includesDesiredVersion(versions, operatorVersion)
📝 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
func excludesOperatorVersion(annotations map[string]string, operatorVersion uint64) bool {
var versionsRaw string
for k, v := range annotations {
if k == "release.openshift.io/major-version" {
versionsRaw = v
break
}
}
if versionsRaw == "" {
return false
}
versions := strings.Split(versionsRaw, ",")
hasOperatorVersion, err := includesDesiredVersion(versions, operatorVersion)
if err != nil {
// Malformed annotation so should be excluded.
return true
}
return !hasOperatorVersion
}
func excludesOperatorVersion(annotations map[string]string, operatorVersion uint64) bool {
var versionsRaw string
for k, v := range annotations {
if k == "release.openshift.io/major-version" {
versionsRaw = v
break
}
}
if versionsRaw == "" {
return false
}
versions := strings.Split(versionsRaw, ",")
for i := range versions {
versions[i] = strings.TrimSpace(versions[i])
}
hasOperatorVersion, err := includesDesiredVersion(versions, operatorVersion)
if err != nil {
// Malformed annotation so should be excluded.
return true
}
return !hasOperatorVersion
}
🤖 Prompt for AI Agents
In pkg/operator/starter.go around lines 368 to 391, the code splits the
annotation value by comma but does not trim whitespace so entries like "4, 5"
produce values with leading spaces and cause includesDesiredVersion to misparse
them; fix by iterating the versions slice after strings.Split, applying
strings.TrimSpace to each element and filtering out any empty strings, then pass
the cleaned slice to includesDesiredVersion (or alternatively trim when building
the versionsRaw) so parsing succeeds for annotations containing spaces.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 2, 2026

@JoelSpeed: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/verify 7e75885 link true /test verify
ci/prow/verify-deps 7e75885 link true /test verify-deps
ci/prow/unit 7e75885 link true /test unit
ci/prow/okd-scos-images 7e75885 link true /test okd-scos-images

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant