Skip to content

OCPBUGS-93739: skip LB Service deletion in HCCO for AWS and actively clean up NLBs during e2e teardown#9052

Open
vsolanki12 wants to merge 2 commits into
openshift:mainfrom
vsolanki12:fix-OCPBUGS-93739
Open

OCPBUGS-93739: skip LB Service deletion in HCCO for AWS and actively clean up NLBs during e2e teardown#9052
vsolanki12 wants to merge 2 commits into
openshift:mainfrom
vsolanki12:fix-OCPBUGS-93739

Conversation

@vsolanki12

@vsolanki12 vsolanki12 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Fixes the CI flake in TestCreateClusterRequestServingIsolation/Teardown where AWS resource cleanup exceeds the 15-minute timeout. The test creates a complex topology (5 management node pools + HA hosted cluster with multi-zone workers), and the NLBs created by the cloud controller take too long to be asynchronously deprovisioned.

Two-part fix:

  1. HCCO: Skip ensureServiceLoadBalancersRemoved for AWS platform. The async cloud controller path (delete Service → CCM deletes NLB) is slow and non-deterministic. NLBs are instead cleaned up directly by the infrastructure destroy flow (DestroyV1ELBs/DestroyV2ELBs), which already deletes all LBs in the VPC.

  2. E2e test: In validateAWSGuestResourcesDeletedFunc, actively delete tagged NLBs/ELBs via the ELBv2 API instead of passively polling for them to disappear. This makes teardown validation faster and deterministic.

This is a targeted step toward the installer-like deprovisioning approach described in HOSTEDCP-1454.

Which issue(s) this PR fixes:

Fixes https://issues.redhat.com/browse/OCPBUGS-93739

Special notes for your reviewer:

  • Non-AWS platforms retain the existing HCCO behavior (delete LB Services, wait for CCM cleanup).
  • DestroyInfra already deletes all LBs in the VPC as a backstop, so no production destroy flow changes are needed.
  • The pre-existing diagnostics (mock interface mismatches in route53/elbv2 tests) are unrelated to this PR.

Checklist:

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

🤖 Generated with Claude Code via /jira:solve OCPBUGS-93739

Summary by CodeRabbit

  • Bug Fixes
    • Improved AWS cleanup by adjusting how load balancer teardown is handled, avoiding unnecessary load balancer Service deletion tracking when infrastructure cleanup performs the removal directly.
    • Enhanced end-to-end cleanup validation to actively delete tagged AWS ALB/NLB load balancers during the polling window.
  • Tests
    • Added a unit test covering the AWS-specific load balancer cleanup behavior.
    • Added end-to-end utility tests for tagged load balancer deletion, including malformed inputs and terminal vs retryable delete error handling.

On AWS, the HCCO previously deleted all non-IngressController-owned
LoadBalancer Services during cloud resource teardown, triggering the
cloud controller to asynchronously delete the backing NLBs. This async
path is non-deterministic and frequently exceeds the e2e teardown
validation timeout for complex topologies (HA, multi-zone, 5+ node
pools).

Skip LoadBalancer Service deletion for AWS. The NLBs are cleaned up
directly via the AWS API in the infrastructure destroy flow
(DestroyV1ELBs/DestroyV2ELBs), which is faster and deterministic.
Non-AWS platforms retain the existing behavior.

Signed-off-by: Vimal Solanki <vsolanki@redhat.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/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. label Jul 22, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 22, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jul 22, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@vsolanki12: This pull request references Jira Issue OCPBUGS-93739, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

What this PR does / why we need it:

Fixes the CI flake in TestCreateClusterRequestServingIsolation/Teardown where AWS resource cleanup exceeds the 15-minute timeout. The test creates a complex topology (5 management node pools + HA hosted cluster with multi-zone workers), and the NLBs created by the cloud controller take too long to be asynchronously deprovisioned.

Two-part fix:

  1. HCCO: Skip ensureServiceLoadBalancersRemoved for AWS platform. The async cloud controller path (delete Service → CCM deletes NLB) is slow and non-deterministic. NLBs are instead cleaned up directly by the infrastructure destroy flow (DestroyV1ELBs/DestroyV2ELBs), which already deletes all LBs in the VPC.

  2. E2e test: In validateAWSGuestResourcesDeletedFunc, actively delete tagged NLBs/ELBs via the ELBv2 API instead of passively polling for them to disappear. This makes teardown validation faster and deterministic.

This is a targeted step toward the installer-like deprovisioning approach described in HOSTEDCP-1454.

Which issue(s) this PR fixes:

Fixes https://issues.redhat.com/browse/OCPBUGS-93739

Special notes for your reviewer:

  • Non-AWS platforms retain the existing HCCO behavior (delete LB Services, wait for CCM cleanup).
  • DestroyInfra already deletes all LBs in the VPC as a backstop, so no production destroy flow changes are needed.
  • The pre-existing diagnostics (mock interface mismatches in route53/elbv2 tests) are unrelated to this PR.

Checklist:

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

🤖 Generated with Claude Code via /jira:solve OCPBUGS-93739

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.

@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: ac2b0365-4ba8-42c4-b3ae-64296d9b20aa

📥 Commits

Reviewing files that changed from the base of the PR and between 215ab6c and 0092592.

📒 Files selected for processing (2)
  • test/e2e/util/fixture.go
  • test/e2e/util/fixture_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/e2e/util/fixture_test.go
  • test/e2e/util/fixture.go

📝 Walkthrough

Walkthrough

AWS cloud resource destruction now skips LoadBalancer Service deletion and waiting on AWS, while preserving existing behavior for other platforms. A unit test verifies this behavior. AWS guest-resource validation now creates an ELBv2 client and actively deletes tagged ELB/NLB resources during each polling iteration, with terminal and retryable deletion errors handled separately.

Sequence Diagram(s)

sequenceDiagram
  participant CleanupValidation
  participant TaggedResources
  participant deleteTaggedLoadBalancers
  participant ELBv2
  CleanupValidation->>TaggedResources: Read tagged resource mappings
  CleanupValidation->>deleteTaggedLoadBalancers: Delete tagged load balancers
  deleteTaggedLoadBalancers->>ELBv2: DeleteLoadBalancer
  CleanupValidation->>TaggedResources: Check remaining guest resources
Loading

Suggested reviewers: ironcladlou, clebs

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning The new e2e teardown path calls external AWS ELBv2 and tagging APIs, so it needs outside-cluster connectivity in disconnected jobs. Guard or skip this path in disconnected CI, or replace it with a cluster-internal cleanup mechanism that does not require AWS API access.
✅ Passed checks (10 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 main AWS-specific HCCO cleanup change and the e2e NLB teardown improvement.
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 test names are static; no new Ginkgo titles or dynamic identifiers appear in the changed files.
Test Structure And Quality ✅ Passed Added tests are narrowly scoped, use fake clients/no cluster cleanup, and the only poll uses PollUntilContextTimeout(15m); no unsafe waits found.
Topology-Aware Scheduling Compatibility ✅ Passed Touched code only changes AWS cleanup/polling and tests; no new pod affinity, node selectors, spread constraints, replicas, or control-plane topology assumptions were added.
No-Weak-Crypto ✅ Passed The PR only changes AWS load-balancer cleanup and tests; no weak crypto, ECB, custom crypto, or secret/token comparisons were added in the touched code.
Container-Privileges ✅ Passed HEAD only changes test/e2e/util/fixture.go and fixture_test.go; neither adds k8s/container privilege fields, and no manifest files were touched.
No-Sensitive-Data-In-Logs ✅ Passed The new logs only mention LB ARNs and generic cleanup status; no credentials, tokens, PII, hostnames, or customer data are logged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vsolanki12
Once this PR has been reviewed and has the lgtm label, please assign enxebre 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 added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Jul 22, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@vsolanki12: This pull request references Jira Issue OCPBUGS-93739, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

What this PR does / why we need it:

Fixes the CI flake in TestCreateClusterRequestServingIsolation/Teardown where AWS resource cleanup exceeds the 15-minute timeout. The test creates a complex topology (5 management node pools + HA hosted cluster with multi-zone workers), and the NLBs created by the cloud controller take too long to be asynchronously deprovisioned.

Two-part fix:

  1. HCCO: Skip ensureServiceLoadBalancersRemoved for AWS platform. The async cloud controller path (delete Service → CCM deletes NLB) is slow and non-deterministic. NLBs are instead cleaned up directly by the infrastructure destroy flow (DestroyV1ELBs/DestroyV2ELBs), which already deletes all LBs in the VPC.

  2. E2e test: In validateAWSGuestResourcesDeletedFunc, actively delete tagged NLBs/ELBs via the ELBv2 API instead of passively polling for them to disappear. This makes teardown validation faster and deterministic.

This is a targeted step toward the installer-like deprovisioning approach described in HOSTEDCP-1454.

Which issue(s) this PR fixes:

Fixes https://issues.redhat.com/browse/OCPBUGS-93739

Special notes for your reviewer:

  • Non-AWS platforms retain the existing HCCO behavior (delete LB Services, wait for CCM cleanup).
  • DestroyInfra already deletes all LBs in the VPC as a backstop, so no production destroy flow changes are needed.
  • The pre-existing diagnostics (mock interface mismatches in route53/elbv2 tests) are unrelated to this PR.

Checklist:

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

🤖 Generated with Claude Code via /jira:solve OCPBUGS-93739

Summary by CodeRabbit

  • Bug Fixes
  • Improved AWS resource cleanup by avoiding unnecessary waits for load balancer Services during infrastructure destruction.
  • Enhanced end-to-end cleanup validation to remove tagged AWS load balancers during cleanup checks.
  • Preserved load balancer deletion tracking and error handling for non-AWS platforms.
  • Tests
  • Added coverage verifying that AWS load balancer Services are not deleted or unnecessarily tracked during cleanup.

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 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: 2

🤖 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 `@test/e2e/util/fixture.go`:
- Around line 410-429: Add a small consumer-side interface for the
DeleteLoadBalancer operation and update deleteTaggedLoadBalancers to depend on
it. Add unit tests covering valid ELB/NLB ARN deletion, non-load-balancer ARN
filtering, malformed ARN handling, and DeleteLoadBalancer failures without
making real AWS calls.
- Around line 423-427: Update deleteTaggedLoadBalancers so DeleteLoadBalancer
errors are classified, returning terminal AWS failures immediately instead of
logging and retrying them until the poll timeout. Keep retries only for
explicitly transient errors, and preserve the existing retry logging and cleanup
behavior for those cases.
🪄 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: 71540313-ab96-4835-9db9-617634628e52

📥 Commits

Reviewing files that changed from the base of the PR and between 97db458 and f520b09.

📒 Files selected for processing (3)
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/resources/resources_test.go
  • test/e2e/util/fixture.go

Comment thread test/e2e/util/fixture.go
Comment thread test/e2e/util/fixture.go Outdated
@vsolanki12
vsolanki12 marked this pull request as ready for review July 22, 2026 11:08
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 22, 2026
@openshift-ci
openshift-ci Bot requested review from clebs and ironcladlou July 22, 2026 11:08

@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 `@test/e2e/util/fixture_test.go`:
- Around line 16-26: Update fakeLoadBalancerDeleter to record every attempted
ARN and return configurable errors per call instead of one shared error. Expand
the transient-error test cases to use two mappings and assert both ARNs are
attempted, while terminal-error cases assert only the first ARN is attempted,
covering the continuation and fail-fast behavior required by the fixture
deletion flow.
🪄 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: 047787df-2787-4a76-8cef-77064cfa40a8

📥 Commits

Reviewing files that changed from the base of the PR and between f520b09 and f1e43fd.

📒 Files selected for processing (2)
  • test/e2e/util/fixture.go
  • test/e2e/util/fixture_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/util/fixture.go

Comment thread test/e2e/util/fixture_test.go
@vsolanki12

Copy link
Copy Markdown
Contributor Author

Manual Verification on Live Cluster

Tested the NLB teardown fix on a live AWS-based HostedCluster.

Setup:

  • Built custom CPO image from branch fix-OCPBUGS-93739
  • Created HostedCluster with release image 5.0.0-ec.4-multi
  • Annotated with custom CPO: hypershift.openshift.io/control-plane-operator-image=ocpbugs-93739-2026-07-22
  • Waited for cluster to reach Available state with healthy KAS

Reproducing the issue (stock CPO):

Created a separate HostedCluster with stock CPO and initiated deletion. HCCO logs showed the slow async LB teardown path ~2 minutes
polling for 6 NLBs:

  14:45:28  "Ensuring load balancers are removed"
  14:45:28  "Waiting on service of type LoadBalancer to be deleted"  service="router-default"
  14:45:29  "Waiting on service of type LoadBalancer to be deleted"  service="test-lb-1"
  ...       (repeated 20+ times over ~2 minutes)
  14:47:21  "Load balancers are removed"

Testing the fix (custom CPO):

Initiated deletion of the HostedCluster running the custom CPO image.

Result:

  HCCO skipped the slow LB Service deletion path entirely:

  16:14:33  "Skipping load balancer Service deletion for AWS; NLBs are cleaned up directly by the infrastructure destroy flow"

  DestroyInfra cleaned up all 5 NLBs directly via the AWS API in ~1 second:

  21:47:39  "Deleted ELB"  id="a15ca1ac..."
  21:47:39  "Deleted ELB"  id="a6fa841e..."
  21:47:39  "Deleted ELB"  id="ab827975..."
  21:47:40  "Deleted ELB"  id="aa549c01..."
  21:47:40  "Deleted ELB"  id="a8aa7477..."

No "Waiting on service of type LoadBalancer to be deleted" messages. Fix working as expected — HCCO skips the async CCM path, DestroyInfra handles NLB cleanup directly.

Introduce a loadBalancerDeleter interface to enable unit testing of
deleteTaggedLoadBalancers without real AWS calls. Classify
OperationNotPermitted and ResourceInUse as terminal errors that abort
the poll loop immediately instead of retrying until timeout.

Signed-off-by: Vimal Solanki <vsolanki@redhat.com>
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.51%. Comparing base (97db458) to head (0092592).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...rconfigoperator/controllers/resources/resources.go 62.50% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9052      +/-   ##
==========================================
+ Coverage   44.44%   44.51%   +0.06%     
==========================================
  Files         774      774              
  Lines       96977    96984       +7     
==========================================
+ Hits        43105    43168      +63     
+ Misses      50897    50828      -69     
- Partials     2975     2988      +13     
Files with missing lines Coverage Δ
...rconfigoperator/controllers/resources/resources.go 57.86% <62.50%> (+0.05%) ⬆️

... and 1 file with indirect coverage changes

Flag Coverage Δ
cmd-support 38.39% <ø> (ø)
cpo-hostedcontrolplane 47.19% <ø> (ø)
cpo-other 45.26% <62.50%> (+0.01%) ⬆️
hypershift-operator 54.44% <ø> (+0.22%) ⬆️
other 32.64% <ø> (ø)

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 23, 2026

Copy link
Copy Markdown
Contributor

@vsolanki12: 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/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/testing Indicates the PR includes changes for e2e testing jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. 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.

2 participants