Skip to content

Commit b66adb8

Browse files
bergmannfclaude
andcommitted
Standardize ResourceBuilder parameter naming to 'rb'
Updated all ResourceBuilder parameters from 'b' to 'rb' for consistency across investigation implementations. Resources references already use 'r' consistently. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 9b4aca0 commit b66adb8

File tree

8 files changed

+25
-16
lines changed

8 files changed

+25
-16
lines changed

cadctl/cmd/investigate/investigate.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,22 @@ func run(cmd *cobra.Command, _ []string) error {
148148
return updateIncidentTitle(pdClient)
149149
}
150150

151-
func handleCADFailure(err error, builder *investigation.ResourceBuilderT, pdClient *pagerduty.SdkClient) {
151+
// handleClusterNotFound centralizes the logic for this specific error case.
152+
func handleClusterNotFound(clusterID string, pdClient *pagerduty.SdkClient, investigationErr error) error {
153+
if investigationErr != nil && strings.Contains(investigationErr.Error(), "no cluster found") {
154+
logging.Warnf("No cluster found with ID '%s'. Escalating and exiting.", clusterID)
155+
return pdClient.EscalateIncidentWithNote("CAD was unable to find the incident cluster in OCM. An alert for a non-existing cluster is unexpected. Please investigate manually.")
156+
}
157+
return investigationErr
158+
}
159+
160+
func handleCADFailure(err error, rb *investigation.ResourceBuilderT, pdClient *pagerduty.SdkClient) {
152161
logging.Errorf("CAD investigation failed: %v", err)
153162

154163
var notes string
155164
// The builder caches resources, so we can access them here even if a later step failed.
156165
// We ignore the error here because we just want to get any notes that were created.
157-
resources, _ := builder.Build()
166+
resources, _ := rb.Build()
158167
if resources != nil && resources.Notes != nil {
159168
resources.Notes.AppendWarning("🚨 CAD investigation failed, CAD team has been notified. Please investigate manually. 🚨")
160169
notes = resources.Notes.String()

pkg/investigations/cannotretrieveupdatessre/cannotretrieveupdatessre.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818
type Investigation struct{}
1919

2020
// Run executes the investigation for the CannotRetrieveUpdatesSRE alert
21-
func (c *Investigation) Run(b investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
21+
func (c *Investigation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
2222
result := investigation.InvestigationResult{}
23-
r, err := b.WithAwsClient().Build()
23+
r, err := rb.WithAwsClient().Build()
2424
if err != nil {
2525
return result, err
2626
}

pkg/investigations/chgm/chgm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ var (
3636
type Investiation struct{}
3737

3838
// Run runs the investigation for a triggered chgm pagerduty event
39-
func (c *Investiation) Run(b investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
39+
func (c *Investiation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
4040
result := investigation.InvestigationResult{}
41-
r, err := b.WithClusterDeployment().Build()
41+
r, err := rb.WithClusterDeployment().Build()
4242
if err != nil {
4343
return result, err
4444
}

pkg/investigations/clustermonitoringerrorbudgetburn/clustermonitoringerrorbudgetburn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const available = "Available"
4545

4646
type Investigation struct{}
4747

48-
func (c *Investigation) Run(b investigation.ResourceBuilder) (result investigation.InvestigationResult, err error) {
49-
r, err := b.Build()
48+
func (c *Investigation) Run(rb investigation.ResourceBuilder) (result investigation.InvestigationResult, err error) {
49+
r, err := rb.Build()
5050
if err != nil {
5151
return investigation.InvestigationResult{}, err
5252
}

pkg/investigations/cpd/cpd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ var byovpcRoutingSL = &ocm.ServiceLog{Severity: "Major", Summary: "Installation
2727
// - always escalate the alert to primary
2828
// The reasoning for this is that we don't fully trust network verifier yet.
2929
// In the future, we want to automate service logs based on the network verifier output.
30-
func (c *Investigation) Run(b investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
30+
func (c *Investigation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
3131
result := investigation.InvestigationResult{}
32-
r, err := b.Build()
32+
r, err := rb.Build()
3333
if err != nil {
3434
return result, err
3535
}

pkg/investigations/insightsoperatordown/insightsoperatordown.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919

2020
type Investigation struct{}
2121

22-
func (c *Investigation) Run(b investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
22+
func (c *Investigation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
2323
result := investigation.InvestigationResult{}
24-
r, err := b.WithAwsClient().Build()
24+
r, err := rb.WithAwsClient().Build()
2525
if err != nil {
2626
return result, err
2727
}

pkg/investigations/machinehealthcheckunterminatedshortcircuitsre/machinehealthcheckunterminatedshortcircuitsre.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ func (i *Investigation) teardown() error {
6060
// The machine object is evaluated first, as it represents a lower-level object that could affect the health of the node.
6161
// If the investigation determines that the breakage is occurring at the machine-level, the corresponding node is *not* investigated.
6262
// After investigating all affected machines, potentially affected nodes are investigated.
63-
func (i *Investigation) Run(b investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
63+
func (i *Investigation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
6464
ctx := context.Background()
6565
result := investigation.InvestigationResult{}
66-
r, err := b.Build()
66+
r, err := rb.Build()
6767
if err != nil {
6868
return result, err
6969
}

pkg/investigations/upgradeconfigsyncfailureover4hr/upgradeconfigsyncfailureover4hr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ const (
2626
remediationName = "upgradeconfigsyncfailureover4hr"
2727
)
2828

29-
func (c *Investigation) Run(b investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
29+
func (c *Investigation) Run(rb investigation.ResourceBuilder) (investigation.InvestigationResult, error) {
3030
result := investigation.InvestigationResult{}
31-
r, err := b.Build()
31+
r, err := rb.Build()
3232
if err != nil {
3333
return result, err
3434
}

0 commit comments

Comments
 (0)