fix(ROSAENG-435): support PagerDuty incident lookup for HCP clusters - #962
fix(ROSAENG-435): support PagerDuty incident lookup for HCP clusters#962fullsend-ai-coder[bot] wants to merge 4 commits into
Conversation
HCP clusters use region-based PD services instead of per-cluster services keyed by DNS base domain. For classic clusters, PD services are named after the cluster's DNS domain, so querying by baseDomain works. For HCP, the PD service corresponds to the AWS region (e.g. us-east-1), and incidents for multiple clusters share the same service. Changes: - Add WithClusterID() to the PD client builder so callers can set a cluster ID for incident filtering - Modify GetFiringAlertsForCluster() to include first_trigger_log_entries when a cluster ID is set, and filter incidents by matching the cluster ID in EventDetails - Add incidentMatchesCluster() helper that checks cluster_id, clusterID, and cluster-id keys in EventDetails - In cmd/cluster/context.go: override baseDomain with the region ID for HCP clusters, and pass externalClusterID (the external UUID) to WithClusterID — PD alerts reference the external UUID, not the internal OCM ID - In cmd/org/context.go: update NewPDClient signature to accept clusterID, detect HCP clusters and pass cluster.ExternalID() The critical fix is using ExternalID() rather than ID() when filtering incidents. PagerDuty alerts contain the cluster's external UUID in their EventDetails, so passing the internal OCM ID would cause incidentMatchesCluster to always return false, filtering out all incidents. Related to ROSAENG-435
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
🤖 Review · Commit: |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fullsend-ai-coder[bot] 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 |
|
Hi @fullsend-ai-coder[bot]. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
🤖 Finished Review · ✅ Success · Started 3:30 PM UTC · Completed 3:48 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $7.76 |
|
Risk Assessment: moderate (2/5) DetailsModerate risk driven primarily by code age — all changed files are mature (last modified 55-1094 days ago). The change is medium-sized (406 lines across 5 files) with good test coverage (40% test file ratio). No protected paths, security-sensitive files, CI, or dependency changes. Bot author with prior contributions. Previous runRisk Assessment: low (1/5) DetailsLow-risk change: moderate line count but well-scoped to 5 files with good test coverage (40% test files), no protected paths or security-sensitive files touched, no dependency or CI changes, bot author with prior contributions, and changed files show low recent churn. Previous run (2)Risk Assessment: moderate (2/5) DetailsSmall-to-medium change (5 files, 404 lines) adding HCP PagerDuty incident lookup support by a bot author. No protected paths, security-sensitive files, CI, or dependency changes. Good test coverage ratio (0.40). cmd/cluster/context.go has notable regression history but no recent churn. Overall risk remains moderate, consistent with prior assessment. Previous run (3)Risk Assessment: moderate (2/5) DetailsSmall focused change (5 files, 296 lines) adding HCP PagerDuty incident lookup support by a bot author. No protected paths, no security-sensitive files, no CI or dependency changes. Good test coverage ratio (0.40). Most files stable for over a year but change scope is well-contained. |
ReviewFindingsLow
Previous runReviewFindingsMedium
Low
Next steps:
Previous run (2)ReviewFindingsMedium
Low
Next steps:
Previous run (3)ReviewFindingsMedium
Low
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 3:49 PM UTC · Completed 4:05 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.01 |
- Add cluster-ID filtering to GetHistoricalAlertsForCluster for HCP clusters, matching the existing filtering in GetFiringAlertsForCluster. Requests first_trigger_log_entries and filters by incidentMatchesCluster when clusterID is set. - Fix pre-existing pagination bug: reset incidentListOffset to 0 at the start of each outer loop iteration over pdServiceIDs in GetFiringAlertsForCluster. - Make HCP detection in generateContextData() consistent with setup() by adding Region() != nil && Region().ID() != "" guards. Addresses #962
🔧 Fix agent — iteration 1 (bot-triggered)Addressed 3 of 5 review findings with code fixes: added cluster-ID filtering to GetHistoricalAlertsForCluster for HCP clusters, fixed the pre-existing pagination offset bug in GetFiringAlertsForCluster, and made the HCP detection guard consistent between setup() and generateContextData(). Disagreed with 2 findings (scope-coherence and api-design-coherence) as out-of-scope refactoring suggestions. All 29 PagerDuty tests pass (2 new). All changed packages compile and pass go vet. Fixed (3):
Disagreed (2):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 4:06 PM UTC · Completed 4:25 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $6.97 |
|
🤖 Finished Fix · ✅ Success · Started 4:26 PM UTC · Completed 4:36 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $1.97 |
- Fix pre-existing bug in GetHistoricalAlertsForCluster where the incidents slice was not reset between service ID iterations, causing inflated IncidentOccurrenceTracker counts for subsequent services - Add debug logging when incidents are filtered out by incidentMatchesCluster to aid HCP incident visibility debugging - Move incidentMatchesCluster tests inside existing Describe block for consistency with test file organization Addresses #962
🔧 Fix agent — iteration 2 (bot-triggered)Fixed incidents slice accumulation bug in GetHistoricalAlertsForCluster, added debug logging for filtered incidents, and reorganized incidentMatchesCluster tests into the existing test structure. All 27 pagerduty tests and the org context test pass. Fixed (3):
Disagreed (1):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 4:38 PM UTC · Completed 5:20 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high |
|
🤖 Finished Fix · ✅ Success · Started 5:21 PM UTC · Completed 5:43 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $2.73 |
- Remove fmt.Printf stdout debug logging that corrupts JSON output when HCP filtering skips incidents; add stderr warning only for nil EventDetails edge case (visibility for silent drops) - Deduplicate HCP region guard: compute once in setup() and store as isHCPRegionBased on contextOptions - Move WithClusterID test to "Client Creation" describe block Addresses #962
🔧 Fix agent — iteration 3 (bot-triggered)Addressed 4 of 8 review findings with code changes: removed stdout-corrupting debug logging, added stderr warning for nil EventDetails edge case, deduplicated HCP guard in cmd/cluster/context.go, and moved WithClusterID test to correct describe block. Recorded reasoned disagreements for the remaining 4 findings (integration test scope, PR title convention, scope coherence observation, future architectural suggestion). Fixed (4):
Disagreed (4):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 5:44 PM UTC · Completed 6:27 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high |
Superseded by updated review
|
/ok-to-test |
|
@fullsend-ai-coder[bot]: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Summary
osdctl cluster contextandosdctl org contextcommandsEventDetailsin the first trigger log entry, ensuring only incidents for the target cluster are shownWhat changed
pkg/provider/pagerduty/pagerduty.goclusterIDfield andWithClusterID()builder method to the PD clientGetFiringAlertsForCluster()to requestfirst_trigger_log_entriesfrom PD and filter incidents by cluster ID when setincidentMatchesCluster()helper that checkscluster_id,clusterID, andcluster-idkeys in EventDetailscmd/cluster/context.gobaseDomainwith the region ID for PD service lookupexternalClusterIDtoWithClusterID()(the external UUID that PD alerts reference)cmd/org/context.goNewPDClientfunction signature to acceptclusterIDparametercluster.ExternalID()for incident filteringTesting
incidentMatchesCluster, 1 forWithClusterID, 4 for HCP filtering inGetFiringAlertsForCluster)cmd/org/context_test.goverifyingNewPDClientpasses both parametersgo vetandgo buildpass on all changed packagesRelated to https://redhat.atlassian.net/browse/ROSAENG-435
Post-script verification
agent/ROSAENG-435-hcp-pagerduty-incidents)c02ab22b7faf938a24ff7f1a084ae3c650f07759..HEAD)