Skip to content

CNTRLPLANE-3693: Refactor nodepool platformConditions signature and extract common platform conditions#9018

Open
hypershift-jira-solve-ci[bot] wants to merge 2 commits into
openshift:mainfrom
hypershift-community:fix-CNTRLPLANE-3693
Open

CNTRLPLANE-3693: Refactor nodepool platformConditions signature and extract common platform conditions#9018
hypershift-jira-solve-ci[bot] wants to merge 2 commits into
openshift:mainfrom
hypershift-community:fix-CNTRLPLANE-3693

Conversation

@hypershift-jira-solve-ci

@hypershift-jira-solve-ci hypershift-jira-solve-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Aligns the setPlatformConditions function signature with other condition-setting functions in conditions.go and extracts common platform image validation into a shared flow.

Refactoring (commit 1):

  • Renames setPlatformConditions to platformConditions with the standard (ctx, nodePool, hcluster) (*ctrl.Result, error) signature, matching other condition setters in the signalConditions slice.
  • Extracts the common NodePoolValidPlatformImageType condition into a new setValidPlatformImageCondition function that dispatches to per-platform image resolution.
  • Separates platform-specific conditions (e.g. AWS security group) into setPlatformSpecificConditions.
  • Splits setAWSConditions into setAWSValidPlatformImage (image condition) and setAWSSecurityGroupCondition (AWS-specific).
  • Renames setKubevirtConditions, setPowerVSconditions, and setOpenStackConditions to setXxxValidPlatformImage to clarify their role in the common image validation flow.

Follow-up fixes (commit 2):

  • Passes already-resolved releaseImage and controlPlaneNamespace into platformConditions instead of re-deriving them, eliminating a redundant getReleaseImage call per reconcile.
  • Simplifies return type from (*ctrl.Result, error) to error since the function never signals a requeue.
  • Removes unused controlPlaneNamespace parameter from setOpenStackValidPlatformImage.
  • Renames TestSetAWSConditions to match its target function and adds test coverage for setAWSSecurityGroupCondition.

No behavioral change — the same conditions are set under the same circumstances, and all existing tests pass.

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/CNTRLPLANE-3693

Special notes for your reviewer:

This is a pure refactoring with no behavioral changes. The primary motivation is to align the platform conditions function signature with the rest of the condition setters and to make the common image validation flow explicit.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Always review AI generated responses prior to use.
Generated with Claude Code via openshift-developer plugin


Note: This PR was auto-generated by the jira-agent periodic CI job in response to CNTRLPLANE-3693. See the full report for token usage, cost breakdown, and detailed phase output.

Summary by CodeRabbit

  • Bug Fixes

    • Improved NodePool platform image validation across AWS, KubeVirt, OpenStack, and PowerVS.
    • Added clearer status reporting when platform images or AWS security groups are unavailable.
    • More consistently reports when AWS worker security group information is ready.
  • Tests

    • Added coverage for platform image validation and AWS security group status conditions.

OpenShift CI Bot and others added 2 commits July 16, 2026 12:31
… common platform conditions

CNTRLPLANE-3693

The setPlatformConditions function had a different signature from other
condition-setting functions in conditions.go. This refactoring:

- Renames setPlatformConditions to platformConditions with the standard
  (ctx, nodePool, hcluster) (*ctrl.Result, error) signature, matching
  other condition setters in the signalConditions slice.
- Extracts the common NodePoolValidPlatformImageType condition into a
  new setValidPlatformImageCondition function that dispatches to
  per-platform image resolution.
- Separates platform-specific conditions (e.g. AWS security group) into
  setPlatformSpecificConditions.
- Splits setAWSConditions into setAWSValidPlatformImage (image condition)
  and setAWSSecurityGroupCondition (AWS-specific).
- Renames setKubevirtConditions, setPowerVSconditions, and
  setOpenStackConditions to setXxxValidPlatformImage to clarify their
  role in the common image validation flow.

No behavioral change — the same conditions are set under the same
circumstances, and all existing tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ions

Pass already-resolved releaseImage and controlPlaneNamespace into
platformConditions instead of re-deriving them, eliminating a redundant
getReleaseImage call per reconcile. Simplify return type from
(*ctrl.Result, error) to error since the function never signals a
requeue. Remove unused controlPlaneNamespace parameter from
setOpenStackValidPlatformImage. Rename TestSetAWSConditions to match
its target function and add test coverage for setAWSSecurityGroupCondition.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 16, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 16, 2026

Copy link
Copy Markdown

@hypershift-jira-solve-ci[bot]: This pull request references CNTRLPLANE-3693 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 task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What this PR does / why we need it:

Aligns the setPlatformConditions function signature with other condition-setting functions in conditions.go and extracts common platform image validation into a shared flow.

Refactoring (commit 1):

  • Renames setPlatformConditions to platformConditions with the standard (ctx, nodePool, hcluster) (*ctrl.Result, error) signature, matching other condition setters in the signalConditions slice.
  • Extracts the common NodePoolValidPlatformImageType condition into a new setValidPlatformImageCondition function that dispatches to per-platform image resolution.
  • Separates platform-specific conditions (e.g. AWS security group) into setPlatformSpecificConditions.
  • Splits setAWSConditions into setAWSValidPlatformImage (image condition) and setAWSSecurityGroupCondition (AWS-specific).
  • Renames setKubevirtConditions, setPowerVSconditions, and setOpenStackConditions to setXxxValidPlatformImage to clarify their role in the common image validation flow.

Follow-up fixes (commit 2):

  • Passes already-resolved releaseImage and controlPlaneNamespace into platformConditions instead of re-deriving them, eliminating a redundant getReleaseImage call per reconcile.
  • Simplifies return type from (*ctrl.Result, error) to error since the function never signals a requeue.
  • Removes unused controlPlaneNamespace parameter from setOpenStackValidPlatformImage.
  • Renames TestSetAWSConditions to match its target function and adds test coverage for setAWSSecurityGroupCondition.

No behavioral change — the same conditions are set under the same circumstances, and all existing tests pass.

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/CNTRLPLANE-3693

Special notes for your reviewer:

This is a pure refactoring with no behavioral changes. The primary motivation is to align the platform conditions function signature with the rest of the condition setters and to make the common image validation flow explicit.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Always review AI generated responses prior to use.
Generated with Claude Code via openshift-developer plugin

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.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The NodePool reconciliation flow now separates valid platform image validation from platform-specific condition handling. Dedicated handlers are used for KubeVirt, AWS, OpenStack, and PowerVS image validation. AWS security group availability is handled independently, with new tests covering missing and present default worker security group IDs. Existing AWS image validation tests now invoke the dedicated handler.

Sequence Diagram(s)

sequenceDiagram
  participant NodePoolReconciler
  participant platformConditions
  participant setValidPlatformImageCondition
  participant setAWSValidPlatformImage
  participant setAWSSecurityGroupCondition
  NodePoolReconciler->>platformConditions: process platform conditions
  platformConditions->>setValidPlatformImageCondition: dispatch image validation
  setValidPlatformImageCondition->>setAWSValidPlatformImage: validate AWS platform image
  setAWSValidPlatformImage->>NodePoolReconciler: update image condition
  platformConditions->>setAWSSecurityGroupCondition: evaluate AWS security group
  setAWSSecurityGroupCondition->>NodePoolReconciler: update security group condition
Loading

Suggested reviewers: sdminonne, muraee

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the refactor of nodepool platformConditions and the extraction of shared platform condition handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The added tests use fixed literal names in table-driven tc.name cases; no generated or interpolated values appear in test titles.
Test Structure And Quality ✅ Passed The added tests are isolated table-driven unit tests, use no cluster waits or shared fixtures, and match existing package style.
Topology-Aware Scheduling Compatibility ✅ Passed Diff only refactors NodePool condition helpers and tests; it adds no pod specs, affinities, spread constraints, selectors, or replica logic.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; the changed tests are plain unit tests with testing.T/NewWithT and no IPv4 or external-connectivity assumptions.
No-Weak-Crypto ✅ Passed Touched files only refactor condition handling/tests; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token compares found.
Container-Privileges ✅ Passed No touched files add container/K8s privilege settings, and the diff contains no privileged/hostPID/hostNetwork/hostIPC/SYS_ADMIN/allowPrivilegeEscalation fields.
No-Sensitive-Data-In-Logs ✅ Passed No new or modified logging statements expose sensitive data; the PR only refactors condition methods and tests, with no sensitive fields added to logs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hypershift-jira-solve-ci[bot]
Once this PR has been reviewed and has the lgtm label, please assign csrwng 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

@openshift-ci
openshift-ci Bot requested review from csrwng and ironcladlou July 16, 2026 12:55
@openshift-ci openshift-ci Bot added area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/aws PR/issue for AWS (AWSPlatform) platform area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform area/platform/openstack PR/issue for OpenStack (OpenStackPlatform) platform area/platform/powervs PR/issue for PowerVS (PowerVSPlatform) platform and removed do-not-merge/needs-area labels Jul 16, 2026

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hypershift-operator/controllers/nodepool/conditions.go`:
- Around line 160-165: Update NodePoolReconciler.platformConditions to invoke
both setValidPlatformImageCondition and setPlatformSpecificConditions regardless
of whether image validation returns an error. Capture each result, preserve
platform-specific condition updates, and return the image-validation error if
present, otherwise return the platform-specific result.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: bf56f93a-1bac-45fb-8311-bb5a5c2740f2

📥 Commits

Reviewing files that changed from the base of the PR and between 73ccc84 and 7f71565.

📒 Files selected for processing (7)
  • hypershift-operator/controllers/nodepool/aws.go
  • hypershift-operator/controllers/nodepool/aws_test.go
  • hypershift-operator/controllers/nodepool/conditions.go
  • hypershift-operator/controllers/nodepool/kubevirt.go
  • hypershift-operator/controllers/nodepool/nodepool_controller.go
  • hypershift-operator/controllers/nodepool/openstack.go
  • hypershift-operator/controllers/nodepool/powervs.go

Comment on lines +160 to +165
func (r *NodePoolReconciler) platformConditions(ctx context.Context, nodePool *hyperv1.NodePool, hcluster *hyperv1.HostedCluster, controlPlaneNamespace string, releaseImage *releaseinfo.ReleaseImage) error {
if err := r.setValidPlatformImageCondition(ctx, nodePool, hcluster, controlPlaneNamespace, releaseImage); err != nil {
return err
}

return r.setPlatformSpecificConditions(nodePool, hcluster)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Run platform-specific conditions even when image validation fails.

The early return at Line 162 prevents setAWSSecurityGroupCondition from updating NodePoolAWSSecurityGroupAvailableConditionType whenever platform-image validation returns an error. Compute both results before returning so AWS security-group status remains independent of image validation.

Suggested fix
 func (r *NodePoolReconciler) platformConditions(ctx context.Context, nodePool *hyperv1.NodePool, hcluster *hyperv1.HostedCluster, controlPlaneNamespace string, releaseImage *releaseinfo.ReleaseImage) error {
-	if err := r.setValidPlatformImageCondition(ctx, nodePool, hcluster, controlPlaneNamespace, releaseImage); err != nil {
-		return err
-	}
-
-	return r.setPlatformSpecificConditions(nodePool, hcluster)
+	imageErr := r.setValidPlatformImageCondition(ctx, nodePool, hcluster, controlPlaneNamespace, releaseImage)
+	platformErr := r.setPlatformSpecificConditions(nodePool, hcluster)
+	if imageErr != nil {
+		return imageErr
+	}
+	return platformErr
 }
📝 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 (r *NodePoolReconciler) platformConditions(ctx context.Context, nodePool *hyperv1.NodePool, hcluster *hyperv1.HostedCluster, controlPlaneNamespace string, releaseImage *releaseinfo.ReleaseImage) error {
if err := r.setValidPlatformImageCondition(ctx, nodePool, hcluster, controlPlaneNamespace, releaseImage); err != nil {
return err
}
return r.setPlatformSpecificConditions(nodePool, hcluster)
func (r *NodePoolReconciler) platformConditions(ctx context.Context, nodePool *hyperv1.NodePool, hcluster *hyperv1.HostedCluster, controlPlaneNamespace string, releaseImage *releaseinfo.ReleaseImage) error {
imageErr := r.setValidPlatformImageCondition(ctx, nodePool, hcluster, controlPlaneNamespace, releaseImage)
platformErr := r.setPlatformSpecificConditions(nodePool, hcluster)
if imageErr != nil {
return imageErr
}
return platformErr
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hypershift-operator/controllers/nodepool/conditions.go` around lines 160 -
165, Update NodePoolReconciler.platformConditions to invoke both
setValidPlatformImageCondition and setPlatformSpecificConditions regardless of
whether image validation returns an error. Capture each result, preserve
platform-specific condition updates, and return the image-validation error if
present, otherwise return the platform-specific result.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.64935% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.13%. Comparing base (73ccc84) to head (7f71565).

Files with missing lines Patch % Lines
hypershift-operator/controllers/nodepool/aws.go 68.42% 16 Missing and 2 partials ⚠️
...rshift-operator/controllers/nodepool/conditions.go 0.00% 16 Missing ⚠️
...pershift-operator/controllers/nodepool/kubevirt.go 0.00% 1 Missing ⚠️
...erator/controllers/nodepool/nodepool_controller.go 0.00% 1 Missing ⚠️
...ershift-operator/controllers/nodepool/openstack.go 0.00% 1 Missing ⚠️
...ypershift-operator/controllers/nodepool/powervs.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9018   +/-   ##
=======================================
  Coverage   44.13%   44.13%           
=======================================
  Files         772      772           
  Lines       96255    96267   +12     
=======================================
+ Hits        42478    42488   +10     
- Misses      50831    50835    +4     
+ Partials     2946     2944    -2     
Files with missing lines Coverage Δ
...pershift-operator/controllers/nodepool/kubevirt.go 0.00% <0.00%> (ø)
...erator/controllers/nodepool/nodepool_controller.go 43.34% <0.00%> (ø)
...ershift-operator/controllers/nodepool/openstack.go 0.00% <0.00%> (ø)
...ypershift-operator/controllers/nodepool/powervs.go 11.32% <0.00%> (ø)
...rshift-operator/controllers/nodepool/conditions.go 54.84% <0.00%> (-0.71%) ⬇️
hypershift-operator/controllers/nodepool/aws.go 82.85% <68.42%> (+2.62%) ⬆️
Flag Coverage Δ
cmd-support 38.24% <ø> (ø)
cpo-hostedcontrolplane 46.17% <ø> (ø)
cpo-other 45.21% <ø> (ø)
hypershift-operator 54.11% <50.64%> (+0.01%) ⬆️
other 32.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@hypershift-jira-solve-ci[bot]: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/aws PR/issue for AWS (AWSPlatform) platform area/platform/kubevirt PR/issue for KubeVirt (KubevirtPlatform) platform area/platform/openstack PR/issue for OpenStack (OpenStackPlatform) platform area/platform/powervs PR/issue for PowerVS (PowerVSPlatform) platform jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant