feat(gcp): add GCP PSC conditions to metrics and platform-specific gauges - #9254
feat(gcp): add GCP PSC conditions to metrics and platform-specific gauges#9254apahim wants to merge 6 commits into
Conversation
Add a tri-state CredentialStatus type (Valid=0, Invalid=1, Unknown=2) and GetCredentialStatus function to the GCP platform package, mirroring the existing AWS pattern in platform/aws. GetCredentialStatus checks ValidGCPWorkloadIdentity and ValidGCPCredentials conditions: returns Invalid if either is False, Valid if both are True, and Unknown otherwise (missing or Unknown conditions). The Unknown state also covers non-GCP clusters naturally, matching AWS behavior. This is a prerequisite for the hypershift_cluster_invalid_gcp_creds Prometheus gauge introduced in a subsequent commit. Signed-off-by: Amador Pahim <apahim@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
… to ExpectedHCConditions Both GCP endpoint access modes (Private and PublicAndPrivate) use Private Service Connect, so PSC conditions are included unconditionally in the GCP case — there is no GCPEndpointAccessPublic constant unlike AWS. This causes PSC failures to appear in the hypershift_hostedclusters_failure_conditions metric. Signed-off-by: Amador Pahim <apahim@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
…trics Track GCP Private Service Connect setup latency and credential validity in Prometheus, mirroring existing AWS metric patterns. Transition duration (hypershift_hosted_cluster_transition_seconds): - Add GCPEndpointAvailable and GCPServiceAttachmentAvailable to the condition slice in collectTransitionDurationMetrics so PSC setup latency is captured in the histogram. Credentials gauge (hypershift_cluster_invalid_gcp_creds): - New gauge emitting 0=valid, 1=invalid, 2=unknown per HostedCluster. - Calls gcp.GetCredentialStatus; non-GCP clusters report Unknown (2), consistent with the AWS collectAwsCredsMetric pattern. - Wired unconditionally into collectPerClusterMetrics. Signed-off-by: Amador Pahim <apahim@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
- Rename all new GCP test case names to follow the required "When ..., it should ..." format per TESTING.md conventions. - Add two mixed False/Unknown condition test cases to TestGetCredentialStatus to cover the contract that False overrides Unknown, producing Invalid status. - Add matching mixed cases to TestReportInvalidGcpCreds expecting gauge value 1. - Fix TestReportTransitionDurationForGCPEndpointConditions case names to follow the same convention. Signed-off-by: Amador Pahim <apahim@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
Add support/conditions/conditions_test.go to cover the GCP-specific conditions added to ExpectedHCConditions. The file had 0% patch coverage as reported by Codecov; these tests bring the GCP case to full coverage. Tests verify that all four GCP-specific conditions are present and set to True for GCP clusters, and absent for non-GCP clusters: - ValidGCPWorkloadIdentity - ValidGCPCredentials - GCPEndpointAvailable - GCPServiceAttachmentAvailable Signed-off-by: Amador Pahim <apahim@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
Signed-off-by: Amador Pahim <apahim@redhat.com> Commit-Message-Assisted-by: Claude (via Claude Code)
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (6)
Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📝 WalkthroughWalkthroughThis change adds tri-state GCP credential evaluation for HostedClusters. The metrics collector exposes credential status and tracks GCP endpoint and service-attachment condition transitions. Expected GCP conditions are marked true for GCP platforms and remain absent for AWS platforms. Tests cover credential states, metric values, transition observations, and platform-specific expected conditions. Sequence Diagram(s)sequenceDiagram
participant HostedCluster
participant MetricsCollector
participant GCPPlatform
participant Prometheus
HostedCluster->>MetricsCollector: provide platform and conditions
MetricsCollector->>GCPPlatform: GetCredentialStatus(HostedCluster)
GCPPlatform-->>MetricsCollector: return credential status
MetricsCollector->>Prometheus: emit GCP metrics
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: apahim The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary
Implements GCP-959 (GA checklist items 6.1, 6.2, 6.3): add PSC connectivity conditions to failure metrics and transition duration histograms, and expose a GCP credential validity gauge.
Changes
1. GCP
GetCredentialStatusfoundation (gcp.go)CredentialStatustype (Valid=0, Invalid=1, Unknown=2) mirroring the AWS patternGetCredentialStatus()inspectingValidGCPWorkloadIdentityandValidGCPCredentialsconditions2. PSC conditions in
ExpectedHCConditions()(support/conditions/conditions.go)GCPEndpointAvailableandGCPServiceAttachmentAvailableto the GCP case unconditionallyhypershift_hostedclusters_failure_conditions3. PSC conditions in transition duration metrics (
metrics.go)GCPEndpointAvailableandGCPServiceAttachmentAvailabletocollectTransitionDurationMetrics()hypershift_hosted_cluster_transition_secondshistogram4.
hypershift_cluster_invalid_gcp_credsgauge (metrics.go)collectGcpCredsMetric()functioncollectPerClusterMetrics()— non-GCP clusters report 2 (unknown)Tests
TestGetCredentialStatus— all condition combinations for the GCP tri-state functionTestReportInvalidGcpCreds— gauge metric collection for all credential statesTestReportTransitionDurationForGCPEndpointConditions— histogram observation for PSC conditionsTestExpectedHCConditionsGCPPlatform— expected conditions for GCP platformJira: https://redhat.atlassian.net/browse/GCP-959
Summary by CodeRabbit
New Features
Bug Fixes