Skip to content

CORS-4516: GCP: Configure cloud provider to use mounted creds - #10733

Open
patrickdillon wants to merge 1 commit into
openshift:mainfrom
patrickdillon:gcd-cloud-config
Open

CORS-4516: GCP: Configure cloud provider to use mounted creds#10733
patrickdillon wants to merge 1 commit into
openshift:mainfrom
patrickdillon:gcd-cloud-config

Conversation

@patrickdillon

@patrickdillon patrickdillon commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

By setting the token-url to nil, we cause cloud-provider-gcp to use the mounted credentials provisioned by the credentialsrequest.

/hold

Depends on openshift/cluster-cloud-controller-manager-operator#493

We might want to just do this for all GCP installs. We could then dump some of the roles from the service account or even make it optional (for users that don't need artifact registry).

Summary by CodeRabbit

  • New Features

    • Added support for configuring a custom token URL in generated GCP cloud-provider configuration.
    • Automatically handles non-standard GCP credential domains by setting the appropriate token URL value.
  • Bug Fixes

    • Improved generated configuration for GCP environments using alternate credential service domains.

By setting the token-url to nil, we cause cloud-provider-gcp to
use the mounted credentials provisioned by the credentialsrequest.
@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 openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Changes

GCP token URL propagation

Layer / File(s) Summary
Token URL configuration rendering
pkg/asset/manifests/gcp/cloudproviderconfig.go, pkg/asset/manifests/gcp/cloudproviderconfig_test.go
The configuration function accepts tokenURL and conditionally renders token-url; tests cover empty and "nil" values.
Session-driven token URL selection
pkg/asset/manifests/cloudproviderconfig.go
GCP generation reads the credentials universe domain and passes "nil" for non-googleapis.com domains.

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

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 No Ginkgo titles were added in the PR; the changed tests use static Go test names like TestCloudProviderConfigWithTokenURL.
Test Structure And Quality ✅ Passed Changed tests are isolated unit tests with one behavior each, include assertion messages, and need no cluster setup/cleanup or timeouts; pattern matches repo.
Microshift Test Compatibility ✅ Passed Only unit tests using testing/testify were added; no new Ginkgo e2e tests or MicroShift-unsupported OpenShift APIs were introduced.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only unit tests and config rendering changed; no new Ginkgo e2e tests or SNO-sensitive assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Only GCP cloud-provider config generation changed; no replicas, affinities, node selectors, tolerations, or topology-spread constraints were added.
Ote Binary Stdout Contract ✅ Passed Touched files are asset-generation code and unit tests only; no main/init/TestMain or stdout logging was introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; only unit tests under pkg/asset/manifests/gcp, with no IPv4-only assumptions or public internet usage.
No-Weak-Crypto ✅ Passed The patch only adds GCP token-url plumbing and tests; no weak algorithms, custom crypto, or secret/token comparisons were introduced.
Container-Privileges ✅ Passed Changed files only generate GCP cloud-provider config; no privileged, hostPID/hostNetwork/hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings appear.
No-Sensitive-Data-In-Logs ✅ Passed No new logging calls in the changed files; token URL is only written to config, not emitted to logs.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: configuring the GCP cloud provider to use mounted credentials.
✨ 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 requested review from barbacbd and sadasu July 30, 2026 18:38
@openshift-ci

openshift-ci Bot commented Jul 30, 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 bfournie 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

@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: 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 `@pkg/asset/manifests/cloudproviderconfig.go`:
- Around line 208-231: Add tests around CloudProviderConfig.Generate that derive
tokenURL from mocked session credentials: verify the default “googleapis.com”
universe omits token-url, while a non-default universe domain renders token-url
as nil. Avoid passing tokenURL directly so the credential-derived selection path
is exercised.
🪄 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: 520c927b-3f6f-43d7-a4c3-1bcd01624544

📥 Commits

Reviewing files that changed from the base of the PR and between dc5aa9c and 8e764af.

📒 Files selected for processing (3)
  • pkg/asset/manifests/cloudproviderconfig.go
  • pkg/asset/manifests/gcp/cloudproviderconfig.go
  • pkg/asset/manifests/gcp/cloudproviderconfig_test.go

Comment on lines +208 to +231
// TODO(padillon): The universe domain comparison can be removed (always set token-url = nil)
// when we want to switch all installs to use the credentialsrequest. Or, when
// https://github.com/kubernetes/cloud-provider-gcp/pull/1261 merges, we can remove this
// entirely from the cloud config.
var tokenURL string
session, err := gcpic.GetSession(ctx)
if err != nil {
return fmt.Errorf("could not get GCP session: %w", err)
}
ud, err := session.Credentials.GetUniverseDomain()
if err != nil {
return fmt.Errorf("could not get GCP universe domain: %w", err)
}
if ud != "" && ud != "googleapis.com" {
tokenURL = "nil"
}

gcpConfig, err := gcpmanifests.CloudProviderConfig(
clusterID.InfraID,
installConfig.Config.GCP.ProjectID,
subnet,
installConfig.Config.GCP.NetworkProjectID,
firewallManagement,
tokenURL,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add generation-path coverage for universe-domain selection.

The renderer test passes "nil" directly, so it does not exercise credential-derived selection. Add CloudProviderConfig.Generate coverage for googleapis.com omitting token-url and a non-default universe domain rendering token-url = nil.

🤖 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 `@pkg/asset/manifests/cloudproviderconfig.go` around lines 208 - 231, Add tests
around CloudProviderConfig.Generate that derive tokenURL from mocked session
credentials: verify the default “googleapis.com” universe omits token-url, while
a non-default universe domain renders token-url as nil. Avoid passing tokenURL
directly so the credential-derived selection path is exercised.

Source: Coding guidelines

@tthvo

tthvo commented Jul 30, 2026

Copy link
Copy Markdown
Member

/cc @rochacbruno

@openshift-ci
openshift-ci Bot requested a review from rochacbruno July 30, 2026 21:47
@patrickdillon

Copy link
Copy Markdown
Contributor Author

/hold cancel

Dependency has merged

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 31, 2026
@tthvo

tthvo commented Jul 31, 2026

Copy link
Copy Markdown
Member

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-azure-nat-gateway-single-zone

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-custom-dns
/test e2e-gcp-custom-endpoints
/test e2e-gcp-default-config
/test e2e-gcp-ovn
/test e2e-gcp-ovn-byo-vpc
/test e2e-gcp-ovn-xpn
/test e2e-gcp-secureboot
/test e2e-gcp-xpn-custom-dns
/test e2e-gcp-xpn-dedicated-dns-project
/test e2e-aws-ovn

@openshift-ci

openshift-ci Bot commented Jul 31, 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/e2e-gcp-custom-dns 8e764af link false /test e2e-gcp-custom-dns
ci/prow/e2e-gcp-xpn-dedicated-dns-project 8e764af link false /test e2e-gcp-xpn-dedicated-dns-project
ci/prow/e2e-gcp-xpn-custom-dns 8e764af link false /test e2e-gcp-xpn-custom-dns
ci/prow/e2e-gcp-ovn-xpn 8e764af link false /test e2e-gcp-ovn-xpn
ci/prow/e2e-gcp-secureboot 8e764af link false /test e2e-gcp-secureboot
ci/prow/e2e-gcp-custom-endpoints 8e764af link false /test e2e-gcp-custom-endpoints
ci/prow/e2e-azure-nat-gateway-single-zone 8e764af link true /test e2e-azure-nat-gateway-single-zone
ci/prow/e2e-gcp-ovn-byo-vpc 8e764af link false /test e2e-gcp-ovn-byo-vpc
ci/prow/e2e-aws-ovn 8e764af link true /test e2e-aws-ovn
ci/prow/gcp-custom-endpoints-proxy-wif 8e764af link false /test gcp-custom-endpoints-proxy-wif

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.

@patrickdillon patrickdillon changed the title GCP: Configure cloud provider to use mounted creds CORS-4516: GCP: Configure cloud provider to use mounted creds Jul 31, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@patrickdillon: This pull request references CORS-4516 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 story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

By setting the token-url to nil, we cause cloud-provider-gcp to use the mounted credentials provisioned by the credentialsrequest.

/hold

Depends on openshift/cluster-cloud-controller-manager-operator#493

We might want to just do this for all GCP installs. We could then dump some of the roles from the service account or even make it optional (for users that don't need artifact registry).

Summary by CodeRabbit

  • New Features

  • Added support for configuring a custom token URL in generated GCP cloud-provider configuration.

  • Automatically handles non-standard GCP credential domains by setting the appropriate token URL value.

  • Bug Fixes

  • Improved generated configuration for GCP environments using alternate credential service domains.

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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