Skip to content

fix(#941): support PagerDuty incident lookup for HCP clusters - #942

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
masterfrom
agent/941-hcp-pagerduty-incidents
Open

fix(#941): support PagerDuty incident lookup for HCP clusters#942
fullsend-ai-coder[bot] wants to merge 1 commit into
masterfrom
agent/941-hcp-pagerduty-incidents

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown

Summary

  • Fixes PagerDuty incident lookup for HCP (Hosted Control Plane) clusters in both osdctl cluster context and osdctl org context commands
  • HCP clusters use region-based PD services instead of per-cluster DNS-based services, so the existing DNS base domain query returned zero results
  • For HCP clusters, queries PD services by the cluster's AWS region and filters incidents by matching cluster ID in the alert's EventDetails
  • Classic clusters continue to use the existing DNS-based lookup unchanged

Approach

PagerDuty provider (pkg/provider/pagerduty):

  • Added WithClusterID() builder method on the PD client
  • When clusterID is set, GetFiringAlertsForCluster includes first_trigger_log_entries in the PD API request and filters incidents by checking EventDetails for a matching cluster ID (supports cluster_id, clusterID, and cluster-id key names)
  • When clusterID is empty (classic clusters), behavior is unchanged

Cluster context (cmd/cluster/context.go):

  • In setup(), detects HCP clusters via cluster.Hypershift().Enabled() and uses the region ID instead of DNS base domain for the PD service query
  • In generateContextData(), passes the cluster ID to the PD client for HCP clusters

Org context (cmd/org/context.go):

  • Extended NewPDClient function signature to accept both baseDomain and clusterID
  • In FetchContext, detects HCP clusters and passes region + cluster ID for filtering

Testing

  • Added unit tests for incidentMatchesCluster covering all key name variants, non-matching, nil EventDetails, and missing key scenarios
  • Added integration-level tests for GetFiringAlertsForCluster with cluster ID filtering: matching, non-matching, alternate keys, and classic (empty clusterID) behavior
  • Added test for updated NewPDClient signature in org context
  • All existing tests continue to pass (25 pagerduty tests, 7 org context tests, 16 cluster context tests)

Closes #941

Post-script verification

  • Branch is not main/master (agent/941-hcp-pagerduty-incidents)
  • Secret scan passed (gitleaks — 13f62d5fbd5f130e861aa956a4709499d18144e9..HEAD)
  • PR body secret scan passed (gitleaks — no-git)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

HCP clusters use region-based PagerDuty services rather than
per-cluster services keyed by DNS base domain. This caused
osdctl cluster context and org context to return zero PD
incidents for HCP clusters.

For HCP clusters, use the cluster's region ID to query PD
services and filter incidents by matching cluster ID in the
first trigger log entry's EventDetails. Classic clusters
continue to use the existing DNS-based lookup unchanged.

Changes:
- pkg/provider/pagerduty: add WithClusterID builder method and
  incidentMatchesCluster filter that checks EventDetails for
  cluster_id when clusterID is set on the client
- cmd/cluster/context: detect HCP clusters in setup() to use
  region-based PD service query and cluster ID filtering
- cmd/org/context: extend NewPDClient to accept clusterID,
  detect HCP clusters in FetchContext to use region-based
  lookup with cluster ID filtering

Note: golangci-lint was not available in the sandbox. go vet
and gofmt passed on all changed packages.

Closes #941
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fullsend-ai-coder[bot]
Once this PR has been reviewed and has the lgtm label, please assign tafhim 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 openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@RaphaelBut

Copy link
Copy Markdown
Contributor

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@fullsend-ai-coder[bot]: all tests passed!

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

ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ROSAENG-435] osdctl cluster context should list PagerDuty incidents for HCP

2 participants