Skip to content

CORS-4420, CORS-4421, CORS-4422, CORS-4449, CORS-4514, CORS-4515: Add GCP Germany Sovereign Cloud support#10630

Open
barbacbd wants to merge 4 commits into
openshift:mainfrom
barbacbd:installer_config_updates_gcd
Open

CORS-4420, CORS-4421, CORS-4422, CORS-4449, CORS-4514, CORS-4515: Add GCP Germany Sovereign Cloud support#10630
barbacbd wants to merge 4 commits into
openshift:mainfrom
barbacbd:installer_config_updates_gcd

Conversation

@barbacbd

@barbacbd barbacbd commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for GCP Germany Sovereign Cloud (GCD) to the OpenShift installer with automatic cloud environment detection, validation, and CAPI
provider configuration.

Changes

Automatic Cloud Environment Detection

  • Implements GetCloudEnvironment() helper that detects sovereign cloud from project ID format
  • eu0: prefix → germany-sovereign cloud
  • No prefix → public GCP
  • No additional user configuration required

Project ID Validation (CORS-4422)

  • Validates project ID format based on detected cloud environment
  • Germany sovereign cloud: requires eu0:<project-name> format
  • Public GCP: rejects project IDs containing : character
  • Provides clear error messages with correct format guidance

Region Validation (CORS-4420, CORS-4449)

  • Adds sovereignCloudRegions map with cloud-specific region lists
  • Germany sovereign cloud regions: europe-west3, europe-west4
  • Implements getValidRegions() and validateRegion() functions
  • Clear error messages listing available regions for each cloud environment

CAPI Provider Configuration (CORS-4421)

  • Configures Cluster API Provider GCP (CAPG) with sovereign cloud endpoints
  • Sets ComputeServiceEndpoint, IAMServiceEndpoint, and ResourceManagerServiceEndpoint
  • Adds cloud-environment: germany-sovereign label to GCPCluster for tracking
  • Automatic detection via GetCloudEnvironment() from project ID

Testing

Validation can be tested with:

  • Valid GCD project ID: eu0:my-project
  • Valid GCD regions: u-germany-northeast1
  • Invalid combinations trigger appropriate error messages

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Germany sovereign cloud environment support for GCP deployments, including sovereign-specific service endpoint selection and the cloud-environment=germany-sovereign label.
    • Added support for setting universeDomain on GCP metadata, including project- and sovereign-aware handling.
  • Improvements

    • Updated platform validation to enforce sovereign project ID formatting and sovereign-specific region allowlisting, with clearer supported-region messaging.
    • Defaulted GCP instance type and disk type using the project ID’s cloud environment (affecting control plane and worker pools).

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

openshift-ci-robot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@barbacbd: This pull request references CORS-4420 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.

This pull request references CORS-4421 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.

This pull request references CORS-4422 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.

This pull request references CORS-4449 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:

Summary

Adds support for GCP Germany Sovereign Cloud (GCD) to the OpenShift installer with automatic cloud environment detection, validation, and CAPI
provider configuration.

Changes

Automatic Cloud Environment Detection

  • Implements GetCloudEnvironment() helper that detects sovereign cloud from project ID format
  • eu0: prefix → germany-sovereign cloud
  • No prefix → public GCP
  • No additional user configuration required

Project ID Validation (CORS-4422)

  • Validates project ID format based on detected cloud environment
  • Germany sovereign cloud: requires eu0:<project-name> format
  • Public GCP: rejects project IDs containing : character
  • Provides clear error messages with correct format guidance

Region Validation (CORS-4420, CORS-4449)

  • Adds sovereignCloudRegions map with cloud-specific region lists
  • Germany sovereign cloud regions: europe-west3, europe-west4
  • Implements getValidRegions() and validateRegion() functions
  • Clear error messages listing available regions for each cloud environment

CAPI Provider Configuration (CORS-4421)

  • Configures Cluster API Provider GCP (CAPG) with sovereign cloud endpoints
  • Sets ComputeServiceEndpoint, IAMServiceEndpoint, and ResourceManagerServiceEndpoint
  • Adds cloud-environment: germany-sovereign label to GCPCluster for tracking
  • Automatic detection via GetCloudEnvironment() from project ID

Testing

Validation can be tested with:

  • Valid GCD project ID: eu0:my-project
  • Valid GCD regions: europe-west3, europe-west4
  • Invalid combinations trigger appropriate error messages

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.

@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from d5d735c to 4d29509 Compare June 17, 2026 16:58
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Germany sovereign cloud support for GCP. A new GetCloudEnvironment helper detects sovereign environments from eu0: project ID prefixes. Validation is extended to enforce sovereign project ID format, region allowlists, and universe domain requirements. Platform and machine pool defaults apply sovereign-specific instance and disk type selections. Cluster manifest generation applies sovereign service endpoint overrides and an AdditionalLabels entry when the environment is detected.

Changes

GCP Germany Sovereign Cloud Support

Layer / File(s) Summary
Cloud environment detection types and contracts
pkg/types/gcp/platform.go, pkg/types/gcp/metadata.go
Adds strings import to platform.go. Exports CloudEnvironmentGermanySovereign constant, adds optional UniverseDomain field to Platform struct, and exports GetCloudEnvironment(projectID string) string that returns "germany-sovereign" for project IDs with eu0: prefix. Adds UniverseDomain field to GCP metadata struct.
Sovereign cloud validation framework
pkg/types/gcp/validation/platform.go
Adds os and logrus imports. Introduces sovereignCloudRegions allowlist map for sovereign environments. Adds validateProjectID (enforces eu0: format for sovereign, rejects : in public), getValidRegions (returns environment-specific region set), and validateRegion (validates region against allowlist, reports sorted valid values on mismatch). Integrates cloud environment derivation and new validation calls into ValidatePlatform, and extends validateUniverseDomain to require universe domain for sovereign and warn on GOOGLE_CLOUD_UNIVERSE_DOMAIN mismatch.
Platform defaults for UniverseDomain
pkg/types/gcp/defaults/platform.go
Updates SetPlatformDefaults to detect cloud environment from project ID and default UniverseDomain to "googleapis.com" for public GCP when unset, while leaving it unset for sovereign cloud.
Machine pool defaults with project-aware disk selection
pkg/types/gcp/machinepools.go, pkg/types/gcp/defaults/machinepool.go
Introduces DefaultDiskTypeForInstanceAndProjectID helper that detects cloud environment from project ID and selects disk type (preferring hyperdisk-balanced for Germany sovereign, pd-ssd for public). Updates DefaultDiskTypeForInstance to delegate to the new function. Updates SetMachinePoolDefaults to pass project ID context when selecting default disk type.
Instance type defaults with project context
pkg/asset/installconfig/gcp/validation.go, pkg/asset/machines/worker.go
Introduces DefaultInstanceTypeForProjectID helper that detects cloud environment from project ID and returns sovereign-specific default (c3-standard-4 for Germany) or architecture-based default for public GCP. Updates control plane and compute pool instance-type defaulting to use the new helper. Updates defaultGCPMachinePoolPlatform signature to accept projectID and use project-aware type selection.
Cluster manifest generation with sovereign endpoints and labels
pkg/asset/manifests/gcp/cluster.go, pkg/asset/cluster/gcp/gcp.go
Extends GenerateClusterAssets to detect germany-sovereign environment and set sovereign compute/IAM/resource-manager service endpoint URLs plus initialize AdditionalLabels with cloud-environment=germany-sovereign label. Wires UniverseDomain from platform config to GCP metadata in Metadata function.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive The custom check requests review of Ginkgo test code quality, but the PR contains no test files. The codebase uses Go's testing package (testify), not Ginkgo. The PR adds 193 lines of source code a... This check is not applicable to the provided pull request context because: (1) The PR adds no test files; (2) The codebase does not use Ginkgo testing framework; (3) The custom check specifically reviews Ginkgo test structure and quality...
✅ 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 clearly and specifically identifies the main change: adding GCP Germany Sovereign Cloud support, with JIRA issue references providing precise context.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
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 This PR is not applicable to this check. The codebase uses Go's standard testing package with testify/assert, not Ginkgo. Zero Ginkgo imports or test patterns found in the repository.
Microshift Test Compatibility ✅ Passed This PR adds no new Ginkgo e2e tests. All 10 modified files are production code for GCP Germany sovereign cloud support, not test files.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added in this PR. All changes are implementation-only (10 Go files with GCP Germany Sovereign Cloud support). The SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed All changes are GCP infrastructure configuration, validation, and defaults code. No Kubernetes pod-level scheduling constraints, anti-affinity rules, topology spread constraints, or nodeSelectors t...
Ote Binary Stdout Contract ✅ Passed No process-level code modifications detected; all changes are in pkg/ library code. Single logrus.Warnf call in validation helper writes to stderr by default, not stdout.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR adds GCP Germany Sovereign Cloud support through configuration and validation code changes, not Ginkgo e2e tests. The custom check only applies to "new Ginkgo e2e tests", which are not pres...
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or non-constant-time secret comparisons found in any modified files.
Container-Privileges ✅ Passed PR contains only Go source code for cloud configuration; no Kubernetes manifests or container specifications with privileged settings were added.
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data exposure in logs. Only new logging added is for universe domain comparison (public domain identifiers), which is safe to log and required for debugging configuration mismatches.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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/types/gcp/validation/platform.go`:
- Around line 225-227: The error message in the field.Invalid call for the
projectID validation is providing incorrect guidance by telling users to set
cloudEnvironment, which is not user-configurable in the install-config. Update
the error message to instead inform users about the supported projectID format
requirements, removing the reference to cloudEnvironment and providing clear,
actionable guidance on what projectID format is expected for public GCP.
- Around line 260-264: The variable errMsg is assigned values on lines 260-263
but is never used, causing a compilation error. Remove the unused errMsg
assignment and construction logic, or alternatively, update the
field.NotSupported() call to use the errMsg variable as the error message
parameter instead of validValues, ensuring the custom error message is actually
included in the validation error that gets appended to allErrs.
🪄 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: 34256dc5-08cf-48df-ae74-27ee08ebaf8e

📥 Commits

Reviewing files that changed from the base of the PR and between 62d23b3 and 4d29509.

📒 Files selected for processing (3)
  • pkg/asset/manifests/gcp/cluster.go
  • pkg/types/gcp/platform.go
  • pkg/types/gcp/validation/platform.go

Comment thread pkg/types/gcp/validation/platform.go Outdated
Comment thread pkg/types/gcp/validation/platform.go Outdated
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch 3 times, most recently from fa4e9e0 to 99d9bed Compare June 17, 2026 19:25
@openshift-ci

openshift-ci Bot commented Jun 17, 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 tthvo 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

@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from 99d9bed to 92064ad Compare June 17, 2026 19:31
@barbacbd barbacbd changed the title CORS-4420, CORS-4421, CORS-4422, CORS-4449: Add GCP Germany Sovereign Cloud support CORS-4420, CORS-4421, CORS-4422, CORS-4449, CORS-4514, CORS-4515: Add GCP Germany Sovereign Cloud support Jun 17, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@barbacbd: This pull request references CORS-4420 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.

This pull request references CORS-4421 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.

This pull request references CORS-4422 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.

This pull request references CORS-4449 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.

This pull request references CORS-4514 which is a valid jira issue.

This pull request references CORS-4515 which is a valid jira issue.

Details

In response to this:

Summary

Adds support for GCP Germany Sovereign Cloud (GCD) to the OpenShift installer with automatic cloud environment detection, validation, and CAPI
provider configuration.

Changes

Automatic Cloud Environment Detection

  • Implements GetCloudEnvironment() helper that detects sovereign cloud from project ID format
  • eu0: prefix → germany-sovereign cloud
  • No prefix → public GCP
  • No additional user configuration required

Project ID Validation (CORS-4422)

  • Validates project ID format based on detected cloud environment
  • Germany sovereign cloud: requires eu0:<project-name> format
  • Public GCP: rejects project IDs containing : character
  • Provides clear error messages with correct format guidance

Region Validation (CORS-4420, CORS-4449)

  • Adds sovereignCloudRegions map with cloud-specific region lists
  • Germany sovereign cloud regions: europe-west3, europe-west4
  • Implements getValidRegions() and validateRegion() functions
  • Clear error messages listing available regions for each cloud environment

CAPI Provider Configuration (CORS-4421)

  • Configures Cluster API Provider GCP (CAPG) with sovereign cloud endpoints
  • Sets ComputeServiceEndpoint, IAMServiceEndpoint, and ResourceManagerServiceEndpoint
  • Adds cloud-environment: germany-sovereign label to GCPCluster for tracking
  • Automatic detection via GetCloudEnvironment() from project ID

Testing

Validation can be tested with:

  • Valid GCD project ID: eu0:my-project
  • Valid GCD regions: u-germany-northeast1
  • Invalid combinations trigger appropriate error messages

Summary by CodeRabbit

Release Notes

  • New Features

  • Added Germany sovereign cloud environment support for GCP deployments, including sovereign-specific service endpoint selection and the cloud-environment=germany-sovereign label.

  • Added support for setting universeDomain on GCP metadata, with sovereign-aware handling.

  • Improvements

  • Updated platform validation to enforce sovereign project ID formatting and sovereign-specific region allowlisting, with better “supported values” feedback.

  • Defaulted GCP instance type and disk type using the project ID’s cloud environment (sovereign vs public), affecting control plane and worker pools.

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

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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/installconfig/gcp/validation.go`:
- Around line 215-216: The code references the package qualifier `gcptypes` on
lines 215-216 in the calls to `GetCloudEnvironment()` and the constant
`CloudEnvironmentGermanySovereign`, but the GCP types package is imported with
the alias `gcp` at line 22. Replace all instances of `gcptypes` with the correct
package alias `gcp` to match the import declaration and resolve the compilation
error.

In `@pkg/types/gcp/machinepools.go`:
- Around line 383-414: Add unit tests for the functions
`DefaultDiskTypeForInstanceAndProjectID` and `GetDiskTypes` in the machinepools
package. The tests should cover disk type selection logic for both public GCP
and sovereign cloud environments, including edge cases such as a3-ultra
instances and fallback behavior when specific disk types are not available.
Create test cases that verify correct disk type assignments for different
instance types and project configurations.

In `@pkg/types/gcp/validation/platform.go`:
- Around line 20-24: The sovereignCloudRegions map for
gcp.CloudEnvironmentGermanySovereign currently only allows u-germany-northeast1,
but the PR documentation specifies that supported Germany sovereign regions are
europe-west3 and europe-west4. Update the sovereignCloudRegions map entry for
gcp.CloudEnvironmentGermanySovereign to replace the u-germany-northeast1 region
with both europe-west3 and europe-west4, each with appropriate display name
mappings.
- Around line 285-286: The logrus.Warnf call that logs the universe domain
mismatch is exposing sensitive internal hostnames/domain information by
including the raw universeDomain and envUniverseDomain values in the log
message. Modify the warning log to remove or sanitize these actual values,
instead logging a generic message that indicates a mismatch exists without
revealing the specific domain details. This prevents leaking internal
infrastructure information into shared logs while still alerting to the
configuration inconsistency.
🪄 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: 98fc7c9a-eca8-44d5-843b-ddcfc0d69d79

📥 Commits

Reviewing files that changed from the base of the PR and between fa4e9e0 and 99d9bed.

📒 Files selected for processing (10)
  • pkg/asset/cluster/gcp/gcp.go
  • pkg/asset/installconfig/gcp/validation.go
  • pkg/asset/machines/worker.go
  • pkg/asset/manifests/gcp/cluster.go
  • pkg/types/gcp/defaults/machinepool.go
  • pkg/types/gcp/defaults/platform.go
  • pkg/types/gcp/machinepools.go
  • pkg/types/gcp/metadata.go
  • pkg/types/gcp/platform.go
  • pkg/types/gcp/validation/platform.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/types/gcp/defaults/machinepool.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/asset/manifests/gcp/cluster.go

Comment thread pkg/asset/installconfig/gcp/validation.go Outdated
Comment thread pkg/types/gcp/machinepools.go Outdated
Comment on lines 383 to 414
func DefaultDiskTypeForInstanceAndProjectID(instanceType, projectID string) string {
defaultDiskType := PDSSD
diskTypes, ok := GetDiskTypes(instanceType)
if ok {
supportedDiskTypes := sets.New(diskTypes...)
switch {
case supportedDiskTypes.Has(PDSSD):
defaultDiskType = PDSSD
case supportedDiskTypes.Has(HyperDiskBalanced):
defaultDiskType = HyperDiskBalanced
default:
// this shouldn't happen because all supported instance types
// have either pd-ssd or hyperdisk balanced
defaultDiskType = diskTypes[0]
cloudEnv := GetCloudEnvironment(projectID)

// Sovereign cloud prefers hyperdisk-balanced
if cloudEnv == CloudEnvironmentGermanySovereign {
switch {
case supportedDiskTypes.Has(HyperDiskBalanced):
defaultDiskType = HyperDiskBalanced
case supportedDiskTypes.Has(PDSSD):
defaultDiskType = PDSSD
default:
defaultDiskType = diskTypes[0]
}
} else {
// Public GCP prefers pd-ssd
switch {
case supportedDiskTypes.Has(PDSSD):
defaultDiskType = PDSSD
case supportedDiskTypes.Has(HyperDiskBalanced):
defaultDiskType = HyperDiskBalanced
default:
// this shouldn't happen because all supported instance types
// have either pd-ssd or hyperdisk balanced
defaultDiskType = diskTypes[0]
}
}
}
return defaultDiskType

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if GetDiskTypes can return empty slice with ok=true
ast-grep --pattern $'func GetDiskTypes($$$) ($_, $_) {
  $$$
}'

Repository: openshift/installer

Length of output: 1012


🏁 Script executed:

#!/bin/bash
# Read the actual code at lines 383-414
sed -n '383,414p' pkg/types/gcp/machinepools.go

Repository: openshift/installer

Length of output: 1053


🏁 Script executed:

#!/bin/bash
# Find the definition of InstanceTypeToDiskTypeMap
rg 'InstanceTypeToDiskTypeMap' pkg/types/gcp/machinepools.go -B 2 -A 10

Repository: openshift/installer

Length of output: 815


🏁 Script executed:

#!/bin/bash
# Check for unit tests for the new function
fd -t f '*_test.go' pkg/types/gcp/ -exec grep -l 'DefaultDiskTypeForInstanceAndProjectID\|GetDiskTypes' {} \;

Repository: openshift/installer

Length of output: 599


🏁 Script executed:

#!/bin/bash
# Find test files in pkg/types/gcp
find pkg/types/gcp -name '*_test.go' -type f

Repository: openshift/installer

Length of output: 150


🏁 Script executed:

#!/bin/bash
# Search for tests related to the new function or GetDiskTypes
rg 'DefaultDiskTypeForInstanceAndProjectID|GetDiskTypes' pkg/types/gcp/ --type go

Repository: openshift/installer

Length of output: 843


🏁 Script executed:

#!/bin/bash
# Check the test files to see what's tested
cat pkg/types/gcp/validation/machinepool_test.go | head -100

Repository: openshift/installer

Length of output: 2530


🏁 Script executed:

#!/bin/bash
# Look for any test related to disk type selection or the new function
rg 'DefaultDiskType|DiskType' pkg/types/gcp/validation/ -B 2 -A 5

Repository: openshift/installer

Length of output: 5516


🏁 Script executed:

#!/bin/bash
# Check if there are any tests in pkg/types/gcp/machinepools.go or related files
find pkg/types/gcp -name '*machinepools*test*.go' -o -name '*test*machinepools*.go'

Repository: openshift/installer

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Search more broadly for tests that test DefaultDiskType or GetDiskTypes
rg 'func.*Test.*Disk|func.*Test.*Default' pkg/types/gcp/ --type go

Repository: openshift/installer

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Verify the guideline requirement for unit tests
# Check if there's any test file for machinepools
ls -la pkg/types/gcp/ | grep -i test

Repository: openshift/installer

Length of output: 45


🏁 Script executed:

#!/bin/bash
# Check the defaults directory where the function is called from
cat pkg/types/gcp/defaults/machinepool.go | head -50

Repository: openshift/installer

Length of output: 1014


Add unit tests for DefaultDiskTypeForInstanceAndProjectID and GetDiskTypes

Code in pkg/ requires unit tests per project guidelines. These functions currently lack test coverage. Add tests to verify disk type selection logic for both public GCP and sovereign cloud environments, including edge cases like a3-ultra instances and fallback behavior.

🤖 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/types/gcp/machinepools.go` around lines 383 - 414, Add unit tests for the
functions `DefaultDiskTypeForInstanceAndProjectID` and `GetDiskTypes` in the
machinepools package. The tests should cover disk type selection logic for both
public GCP and sovereign cloud environments, including edge cases such as
a3-ultra instances and fallback behavior when specific disk types are not
available. Create test cases that verify correct disk type assignments for
different instance types and project configurations.

Comment thread pkg/types/gcp/validation/platform.go Outdated
Comment thread pkg/types/gcp/validation/platform.go Outdated
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from 92064ad to 6add22b Compare June 17, 2026 19:54

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

There's a lot of good stuff here, but we need to edit down somewhat ruthlessly to focus just on the core type stuff, like passing in the universe domain and setting it.

gcd sovereign clouds will extend to many more regions, all of the others would most likely be outside germany, so let's drop the specifics about german cloud

If we need to switch on gcd, let's make an isGCD function that determines we're running on gcd. Right now you're making that on the eu0 prefix, but I think we might see more prefixes. Perhaps we do it solely based on the :? I don't know if there are any other indicating factors, especially if we make universe domain optional.

I do wonder whether we even need an isGCD function? The main need I'm aware of is to switch on instance type, and maybe also disk type? There is an API that would get us at least available instance types.

Comment thread pkg/types/gcp/validation/platform.go Outdated
Comment thread pkg/types/gcp/defaults/platform.go Outdated
Comment thread pkg/types/gcp/platform.go Outdated
Comment thread pkg/types/gcp/validation/platform.go Outdated
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch 2 times, most recently from 1a3a9b5 to 30f1139 Compare June 18, 2026 14:00
Comment thread pkg/asset/manifests/gcp/cluster.go Outdated
Comment thread pkg/asset/manifests/gcp/cluster.go Outdated
Comment thread pkg/asset/installconfig/gcp/validation.go Outdated
Comment thread pkg/types/gcp/validation/platform.go Outdated
Comment thread pkg/types/gcp/platform.go
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from 30f1139 to e0ba5ca Compare June 22, 2026 14:17

@rochacbruno rochacbruno left a comment

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.

Added some comments and also noted that pkg/destroy/gcp/gcp.go must also have GOOGLE_CLOUD_UNIVERSE_DOMAIN otherwise will break sovereign cloud cluster terdown.

Comment thread pkg/types/gcp/platform.go
Comment thread pkg/types/gcp/platform.go
Comment thread pkg/types/gcp/platform.go Outdated
Comment thread pkg/asset/installconfig/gcp/validation.go Outdated
Comment thread pkg/asset/installconfig/gcp/validation.go Outdated
Comment thread pkg/types/gcp/validation/platform.go Outdated
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch 4 times, most recently from 154b684 to 0e41475 Compare June 23, 2026 18:30
"github.com/openshift/installer/pkg/types"
dnstypes "github.com/openshift/installer/pkg/types/dns"
"github.com/openshift/installer/pkg/types/gcp"
gcptypes "github.com/openshift/installer/pkg/types/gcp"

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.

This change doesn't seem necessary and adds a bunch of noise to the pr

@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from 0e41475 to 5a0c6e4 Compare June 23, 2026 18:36
Comment thread pkg/types/gcp/validation/platform.go Outdated
Comment on lines +229 to +241
// validateSovereignCloudRegion validates that sovereign cloud projects use appropriate region formats.
func validateSovereignCloudRegion(projectID, region, cloudEnvironment string, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

if cloudEnvironment == gcp.CloudEnvironmentSovereign {
// Sovereign cloud regions should use the u- prefix format
if region != "" && !strings.HasPrefix(region, "u-") {
allErrs = append(allErrs, field.Invalid(fldPath, region,
"sovereign cloud projects should use regions with 'u-' prefix (e.g., u-germany-northeast1)"))
}
}

return allErrs

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.

can we just depend on the gcp sdk/api to validate the user-provided region? what happens if users input an invalid region without this validation? if they get back a useful error message, I think we're fine without this.

@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from 5a0c6e4 to d422ca0 Compare June 23, 2026 20:55
Comment thread pkg/types/gcp/platform.go Outdated
// GetCloudEnvironmentWithRegion determines the cloud environment using project ID and region.
// A known sovereign cloud prefix in the project ID is definitive.
// This prevents misclassifying organization-scoped public GCP projects (orgname:project-id).
func GetCloudEnvironmentWithRegion(projectID, region string) string {

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.

Looks like parameter region is not being used as we can rely the project prefix, right? Maybe we can simplify the code as:

var (
	// sovereignCloudProjectPrefixes contains known project ID prefixes for sovereign clouds.
	// Project IDs in sovereign clouds use the format: <prefix>:<project-id>
	// This list helps distinguish from organization-scoped public GCP projects (orgname:project-id).
	sovereignCloudProjectPrefixes = []string{
		"eu0:", // European sovereign cloud (Germany)
	}
)

// GetCloudEnvironment determines the cloud environment from the project ID format.
// Returns CloudEnvironmentSovereign for sovereign cloud environments, empty string for public GCP.
// Uses known sovereign cloud project ID prefixes to distinguish from organization-scoped
// public GCP projects (orgname:project-id).
func GetCloudEnvironment(projectID string) string {
	// Check if project ID has a known sovereign cloud prefix
	for _, prefix := range sovereignCloudProjectPrefixes {
		if strings.HasPrefix(projectID, prefix) {
			return CloudEnvironmentSovereign
		}
	}
	return ""
}

Comment thread pkg/types/gcp/platform.go Outdated
Comment on lines +221 to +223
// For non-sovereign colon-formatted projects (e.g., orgname:project-id),
// strip the prefix for backward compatibility
projectID = parts[1]

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'm curious if we should strip the prefix here, because, previously, we just pass in the projectID directly 🤔

If we were incorrect before, then wouldn't the email be in format @<project-id>.<org-prefix>.iam.gserviceaccount.com too? See kubeflow/kubeflow#2244

Comment thread pkg/types/gcp/platform.go
// For public GCP, this should be left empty (defaults to googleapis.com).
// For sovereign clouds like GCD, set this to the appropriate domain (e.g., apis-berlin-build0.goog).
// +optional
UniverseDomain string `json:"universeDomain,omitempty"`

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.

Looks like you need another go generate ./pkg/types/installconfig.go :D

@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch 6 times, most recently from e36735e to 26b2e0d Compare June 24, 2026 12:52
barbacbd added 3 commits June 24, 2026 15:57
Add UniverseDomain field to the GCP platform configuration to support
sovereign cloud environments that use different API endpoints.

The universe domain specifies which GCP universe the cluster operates in.
Public GCP uses googleapis.com (the default), while sovereign clouds use
their own universe domains (e.g., apis-berlin-build0.goog for the German
sovereign cloud).

This field is validated to ensure it's only set when using sovereign cloud
project IDs (those with a colon prefix like eu0:project-id).
Update credential loading to use CredentialsFromJSONWithParams and
FindDefaultCredentialsWithParams, which automatically extract and apply
the universe domain from the credentials JSON.

Explicitly set the universe domain on all GCP service clients when it
differs from the default googleapis.com. This ensures all GCP API calls
use the correct endpoints for sovereign cloud environments.

Without this, API calls would attempt to use googleapis.com endpoints
even when credentials specify a different universe domain, resulting in
authentication failures.
Configure default instance and disk types for sovereign cloud regions.
Sovereign clouds have limited machine type availability compared to
public GCP.

Use c3-standard-4 instances and hyperdisk-balanced disks as defaults
for sovereign cloud regions (those with 'u-' prefix), as these types
are available in sovereign clouds while the standard defaults
(n2-standard-4 and pd-ssd) are not.
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from 1e18f7a to 218a44f Compare June 24, 2026 19:58
func (f *contentLoader) Load(ctx context.Context) (*googleoauth.Credentials, error) {
return googleoauth.CredentialsFromJSON(ctx, []byte(f.content), compute.CloudPlatformScope)
// Use CredentialsFromJSONWithParams to ensure universe domain from credentials is applied
return googleoauth.CredentialsFromJSONWithParams(ctx, []byte(f.content), googleoauth.CredentialsParams{

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 think CredentialsFromJSON internally calls CredentialsFromJSONWithParams already, right?

Comment thread pkg/asset/installconfig/gcp/services.go Outdated

// Explicitly set universe domain from credentials if present
// This is required for sovereign clouds which use a different universe domain
universeDomain := ssn.Credentials.UniverseDomain()

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.

UniverseDomain func is deprecated. We should call GetUniverseDomain instead:

ud, err := ssn.Credentials.GetUniverseDomain()
if err != nil {
	return nil, fmt.Errorf("failed to get universe domain: %w", err)
}

@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch 2 times, most recently from 18fe01a to b887781 Compare June 25, 2026 00:21
The GCP Cluster API provider needs the GOOGLE_CLOUD_UNIVERSE_DOMAIN
environment variable set to use the correct API endpoints in sovereign
cloud environments.

Without this, the CAPI provider attempts to use the default googleapis.com
endpoints even when credentials contain a different universe domain,
resulting in errors like:

  the configured universe domain ("googleapis.com") does not match
  the universe domain found in the credentials ("apis-berlin-build0.goog")

Extract the universe domain from the GCP session credentials and set it
as an environment variable for the CAPG infrastructure controller when it
differs from the default googleapis.com.

Also update universe domain validation to make it optional - users can
provide it explicitly in install-config, or let the GCP SDK extract it
from credentials automatically.
@barbacbd barbacbd force-pushed the installer_config_updates_gcd branch from b887781 to 7ac111d Compare June 25, 2026 01:12
@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@barbacbd: 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-endpoints 7ac111d link false /test e2e-gcp-custom-endpoints
ci/prow/e2e-gcp-custom-dns 7ac111d link false /test e2e-gcp-custom-dns
ci/prow/e2e-gcp-ovn-byo-vpc 7ac111d link false /test e2e-gcp-ovn-byo-vpc
ci/prow/e2e-gcp-ovn-xpn 7ac111d link false /test e2e-gcp-ovn-xpn
ci/prow/e2e-gcp-xpn-dedicated-dns-project 7ac111d link false /test e2e-gcp-xpn-dedicated-dns-project
ci/prow/e2e-gcp-default-config 7ac111d link false /test e2e-gcp-default-config
ci/prow/e2e-gcp-xpn-custom-dns 7ac111d link false /test e2e-gcp-xpn-custom-dns
ci/prow/gcp-custom-endpoints-proxy-wif 7ac111d link false /test gcp-custom-endpoints-proxy-wif
ci/prow/gcp-private 7ac111d link false /test gcp-private
ci/prow/e2e-gcp-ovn 7ac111d link true /test e2e-gcp-ovn
ci/prow/e2e-gcp-secureboot 7ac111d link false /test e2e-gcp-secureboot

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

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.

5 participants