Skip to content

OCPBUGS-100189: Patch GCP Load Balancer Health Checks - #10731

Open
patrickdillon wants to merge 1 commit into
openshift:mainfrom
patrickdillon:gcp-lb-healthcheck-hook
Open

OCPBUGS-100189: Patch GCP Load Balancer Health Checks#10731
patrickdillon wants to merge 1 commit into
openshift:mainfrom
patrickdillon:gcp-lb-healthcheck-hook

Conversation

@patrickdillon

@patrickdillon patrickdillon commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This commit adds a hook to patch the default load balancer health check values populated by CAPG in order to match the values used by Terraform. The non-configurable CAPG defaults are very lax & this can cause failures during bootstrapping, because the API server on a node frequently goes offline as it bootstraps. The lax health checks means the offline node will stay in the pool and the LB will continue to serve connections to the offline node.

As pods try to connect to the API server and fail because the request is sent to an offline API server, the pod may throw an error and fall into CrashLoopBackoff.

Instead, the offline API server should be pulled from the LB pool very quickly so that traffic continues to be routed to the bootstrap API server, which stays available throughout bootstrapping.

The preferred method for handling this is through CAPG:

kubernetes-sigs/cluster-api-provider-gcp#1732

proposes an API for the health checks. Once that merges, we can remove this hook, but this hook is valuable for immediate gain as well as backporting to previous versions, where we might not be able to bump CAPG.

Summary by CodeRabbit

  • New Features

    • Improved GCP cluster load balancer health checks by applying faster legacy-style interval/timeout and updated healthy/unhealthy thresholds.
    • Updates are applied to both public and internal API health checks where applicable.
  • Bug Fixes

    • Cluster post-provisioning now reports failures when health-check updates can’t be applied, instead of silently succeeding.

@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 jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. 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 29, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@patrickdillon: This pull request references Jira Issue OCPBUGS-100189, 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 New, 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:

This commit adds a hook to patch the default load balancer health check values populated by CAPG in order to match the values used by Terraform. The non-configurable CAPG defaults are very lax & this can cause failures during bootstrapping, because the API server on a node frequently goes offline as it bootstraps. The lax health checks means the offline node will stay in the pool and the LB will continue to serve connections to the offline node.

As pods try to connect to the API server and fail because the request is sent to an offline API server, the pod may throw an error and fall into CrashLoopBackoff.

Instead, the offline API server should be pulled from the LB pool very quickly so that traffic continues to be routed to the bootstrap API server, which stays available throughout bootstrapping.

The preferred method for handling this is through CAPG:

kubernetes-sigs/cluster-api-provider-gcp#1732

proposes an API for the health checks. Once that merges, we can remove this hook, but this hook is valuable for immediate gain as well as backporting to previous versions, where we might not be able to bump CAPG.

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

Copy link
Copy Markdown

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

Run ID: c3cb41d7-6726-438a-a87a-f81893a32bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5c0d6 and 9380896.

📒 Files selected for processing (2)
  • pkg/infrastructure/gcp/clusterapi/clusterapi.go
  • pkg/infrastructure/gcp/clusterapi/healthcheck.go

📝 Walkthrough

Walkthrough

Changes

GCP health-check updates

Layer / File(s) Summary
Health-check settings and orchestration
pkg/infrastructure/gcp/clusterapi/healthcheck.go
Defines fixed legacy timing and threshold values, creates the Compute Engine client, derives health-check names, and conditionally updates global and regional checks.
Health-check operation completion
pkg/infrastructure/gcp/clusterapi/healthcheck.go
Patches global and regional health checks and waits for their operations with three-minute timeouts.
Post-provisioning hook integration
pkg/infrastructure/gcp/clusterapi/clusterapi.go
Runs health-check updates during PostProvision and wraps failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: patching GCP load balancer health checks.
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 Only production code changed; no Ginkgo specs or test titles were added or modified.
Test Structure And Quality ✅ Passed No Ginkgo tests were added or changed in this commit; only production files were modified, so the test-structure check is not applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo tests were added; the PR only changes GCP infrastructure hook code, so MicroShift test compatibility is not implicated.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the PR changes GCP clusterapi infra code and unit-test files only, with no SNO-unsafe specs found.
Topology-Aware Scheduling Compatibility ✅ Passed Only GCP health-check patching changed; no pod manifests, replicas, affinity, nodeSelectors, or topology-spread constraints were added.
Ote Binary Stdout Contract ✅ Passed PR only adds library health-check logic; no main/init/TestMain/suite setup or stdout prints were introduced, and logging is via logrus.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests were added in this PR; only GCP clusterapi code changed, so the IPv4/disconnected-network check is not applicable.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons were added in the changed files.
Container-Privileges ✅ Passed PR only changes two Go files for CAPG health-check patching; no container/K8s manifest or privilege settings were added.
No-Sensitive-Data-In-Logs ✅ Passed New logs only announce health-check updates by InfraID-derived resource name; no passwords, tokens, PII, or host/customer data are logged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@patrickdillon

Copy link
Copy Markdown
Contributor Author

/test e2e-gcp-ovn

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign barbacbd 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-robot

Copy link
Copy Markdown
Contributor

@patrickdillon: This pull request references Jira Issue OCPBUGS-100189, 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:

This commit adds a hook to patch the default load balancer health check values populated by CAPG in order to match the values used by Terraform. The non-configurable CAPG defaults are very lax & this can cause failures during bootstrapping, because the API server on a node frequently goes offline as it bootstraps. The lax health checks means the offline node will stay in the pool and the LB will continue to serve connections to the offline node.

As pods try to connect to the API server and fail because the request is sent to an offline API server, the pod may throw an error and fall into CrashLoopBackoff.

Instead, the offline API server should be pulled from the LB pool very quickly so that traffic continues to be routed to the bootstrap API server, which stays available throughout bootstrapping.

The preferred method for handling this is through CAPG:

kubernetes-sigs/cluster-api-provider-gcp#1732

proposes an API for the health checks. Once that merges, we can remove this hook, but this hook is valuable for immediate gain as well as backporting to previous versions, where we might not be able to bump CAPG.

Summary by CodeRabbit

  • New Features

  • Improved GCP cluster health checks with faster response intervals and updated healthy/unhealthy thresholds.

  • Applied health-check updates to both public and internal API load balancers where applicable.

  • Bug Fixes

  • Added automatic retries for temporary cloud service failures during health-check updates.

  • Improved handling of interrupted or timed-out health-check operations.

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 requested review from barbacbd and rochacbruno July 29, 2026 22:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@pkg/infrastructure/gcp/clusterapi/healthcheck.go`:
- Around line 37-76: Add unit tests covering updateHealthChecks orchestration
and public/private target selection in
pkg/infrastructure/gcp/clusterapi/healthcheck.go:37-76, retry and cancellation
behavior plus terminal failures in
pkg/infrastructure/gcp/clusterapi/healthcheck.go:78-169, and PostProvision error
propagation in pkg/infrastructure/gcp/clusterapi/clusterapi.go:311-318. Use
mocked compute-service interactions to verify global/regional PATCH retries and
interruption outcomes.
- Around line 108-112: Update both retry-error branches in healthcheck.go at
lines 108-112 and 147-151: in the wait.Interrupted handling, wrap waitErr as the
primary error so cancellations and deadlines retain their correct identity, and
include lastErr only as supplemental context when available. Preserve direct
return of non-interrupted waitErr errors.
🪄 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: 1375355c-7993-4168-aee0-9b09260228b5

📥 Commits

Reviewing files that changed from the base of the PR and between 759698c and 6d5c0d6.

📒 Files selected for processing (2)
  • pkg/infrastructure/gcp/clusterapi/clusterapi.go
  • pkg/infrastructure/gcp/clusterapi/healthcheck.go

Comment thread pkg/infrastructure/gcp/clusterapi/healthcheck.go
Comment thread pkg/infrastructure/gcp/clusterapi/healthcheck.go Outdated
@patrickdillon

Copy link
Copy Markdown
Contributor Author

/test verify-vendor

@patrickdillon patrickdillon changed the title OCPBUGS-100189: patch load balancer health checks OCPBUGS-100189: Patch GCP Load Balancer Health Checks Jul 30, 2026
This commit adds a hook to patch the default load balancer health
check values populated by CAPG in order to match the values used
by Terraform. The non-configurable CAPG defaults are very lax &
this can cause failures during bootstrapping, because the API
server on a node frequently goes offline as it bootstraps. The lax
health checks means the offline node will stay in the pool and the
LB will continue to serve connections to the offline node.

As pods try to connect to the API server and fail because the request
is sent to an offline API server, the pod may throw an error and
fall into CrashLoopBackoff.

Instead, the offline API server should be pulled from the LB pool
very quickly so that traffic continues to be routed to the bootstrap
API server, which stays available throughout bootstrapping.

The preferred method for handling this is through CAPG:

kubernetes-sigs/cluster-api-provider-gcp#1732

proposes an API for the health checks. Once that merges, we can
remove this hook, but this hook is valuable for immediate gain as
well as backporting to previous versions, where we might not be
able to bump CAPG.
@patrickdillon
patrickdillon force-pushed the gcp-lb-healthcheck-hook branch from 6d5c0d6 to 9380896 Compare July 30, 2026 01:35
@patrickdillon

Copy link
Copy Markdown
Contributor Author

/test e2e-gcp-ovn

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@patrickdillon: This pull request references Jira Issue OCPBUGS-100189, 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)

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

Details

In response to this:

This commit adds a hook to patch the default load balancer health check values populated by CAPG in order to match the values used by Terraform. The non-configurable CAPG defaults are very lax & this can cause failures during bootstrapping, because the API server on a node frequently goes offline as it bootstraps. The lax health checks means the offline node will stay in the pool and the LB will continue to serve connections to the offline node.

As pods try to connect to the API server and fail because the request is sent to an offline API server, the pod may throw an error and fall into CrashLoopBackoff.

Instead, the offline API server should be pulled from the LB pool very quickly so that traffic continues to be routed to the bootstrap API server, which stays available throughout bootstrapping.

The preferred method for handling this is through CAPG:

kubernetes-sigs/cluster-api-provider-gcp#1732

proposes an API for the health checks. Once that merges, we can remove this hook, but this hook is valuable for immediate gain as well as backporting to previous versions, where we might not be able to bump CAPG.

Summary by CodeRabbit

  • New Features

  • Improved GCP cluster load balancer health checks by applying faster legacy-style interval/timeout and updated healthy/unhealthy thresholds.

  • Updates are applied to both public and internal API health checks where applicable.

  • Bug Fixes

  • Cluster post-provisioning now reports failures when health-check updates can’t be applied, instead of silently succeeding.

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

Copy link
Copy Markdown
Contributor

@patrickdillon: 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/gcp-custom-endpoints-proxy-wif 9380896 link false /test gcp-custom-endpoints-proxy-wif
ci/prow/gcp-private 9380896 link false /test gcp-private

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.

ctx, cancel := context.WithTimeout(ctx, time.Minute*3)
defer cancel()

op, err := svc.HealthChecks.Patch(projectID, hcName, hcPatch).Context(ctx).Do()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if a retry pattern is needed here? what happens if CAPG hasn't finished creating the health check resources by the time PostProvision runs? it will fail with 404.

I see iam.go uses a retry loop with back-off

retryTime = 10 * time.Second

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am wondering about this exact same thing: how do we make sure these calls are resilient?

The original implementation wrapped the call in an exponential backoff, and it failed because the implementation was buggy. It seemed like that was overly complex: the current implementation uses relatively simple calls to send the operator to GCP, which should process them, handle issues server side, and only return an error when it is a legitimate failure. Is that enough resiliency? I think so but I'm not sure.

Specifically the CAPG health checks are guaranteed (supposedly) to be created by the InfrastructureReady check. This call only runs after InfrastructureReady, in which case CAPG has reconciled the load balancer.

In the IAM case, we are creating those resources directly with the SDK (not created by CAPG). And IAM is notoriously slow to be eventually consistent.

I am very open to the idea of adding some resiliency, but I'm leaning toward testing out how resilient the current implementation is in CI...

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

Labels

jira/severity-important Referenced Jira bug's severity is important 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.

3 participants