Skip to content

Commit 417d3f4

Browse files
committed
Remove investigationName from result.
The name is already known at the call-site.
1 parent 8f45fc8 commit 417d3f4

File tree

6 files changed

+12
-24
lines changed

6 files changed

+12
-24
lines changed

cadctl/cmd/investigate/investigate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ func run(_ *cobra.Command, _ []string) error {
120120

121121
customerAwsClient, err := managedcloud.CreateCustomerAWSClient(cluster, ocmClient)
122122
if err != nil {
123-
ccamResources := &investigation.Resources{Cluster: cluster, ClusterDeployment: clusterDeployment, AwsClient: customerAwsClient, OcmClient: ocmClient, PdClient: pdClient, AdditionalResources: map[string]interface{}{"alertType": alertInvestigation.Name, "error": err}}
123+
ccamResources := &investigation.Resources{Cluster: cluster, ClusterDeployment: clusterDeployment, AwsClient: customerAwsClient, OcmClient: ocmClient, PdClient: pdClient, AdditionalResources: map[string]interface{}{"error": err}}
124124
result, err := ccam.Investigate(ccamResources)
125-
updateMetrics(&result)
125+
updateMetrics(alertInvestigation.Name, &result)
126126
return err
127127
}
128128

129129
investigationResources := &investigation.Resources{Cluster: cluster, ClusterDeployment: clusterDeployment, AwsClient: customerAwsClient, OcmClient: ocmClient, PdClient: pdClient}
130130

131131
logging.Infof("Starting investigation for %s", alertInvestigation.Name)
132132
result, err := alertInvestigation.Run(investigationResources)
133-
updateMetrics(&result)
133+
updateMetrics(alertInvestigation.Name, &result)
134134
return err
135135
}
136136

@@ -176,14 +176,14 @@ func clusterRequiresInvestigation(cluster *cmv1.Cluster, pdClient *pagerduty.Sdk
176176
return true, nil
177177
}
178178

179-
func updateMetrics(result *investigation.InvestigationResult) {
179+
func updateMetrics(investigationName string, result *investigation.InvestigationResult) {
180180
if result.ServiceLogSent.Performed {
181-
metrics.Inc(metrics.ServicelogSent, append([]string{result.InvestigationName}, result.ServiceLogSent.Labels...)...)
181+
metrics.Inc(metrics.ServicelogSent, append([]string{investigationName}, result.ServiceLogSent.Labels...)...)
182182
}
183183
if result.ServiceLogPrepared.Performed {
184-
metrics.Inc(metrics.ServicelogPrepared, append([]string{result.InvestigationName}, result.ServiceLogPrepared.Labels...)...)
184+
metrics.Inc(metrics.ServicelogPrepared, append([]string{investigationName}, result.ServiceLogPrepared.Labels...)...)
185185
}
186186
if result.LimitedSupportSet.Performed {
187-
metrics.Inc(metrics.LimitedSupportSet, append([]string{result.InvestigationName}, result.LimitedSupportSet.Labels...)...)
187+
metrics.Inc(metrics.LimitedSupportSet, append([]string{investigationName}, result.LimitedSupportSet.Labels...)...)
188188
}
189189
}

pkg/investigations/ccam/ccam.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ func Investigate(r *investigation.Resources) (investigation.InvestigationResult,
2424
cluster := r.Cluster
2525
ocmClient := r.OcmClient
2626
pdClient := r.PdClient
27-
alertType, ok := r.AdditionalResources["alertType"].(string)
28-
if !ok {
29-
return result, fmt.Errorf("Missing required CCAM field 'alertType'")
30-
}
31-
result.InvestigationName = alertType
3227
bpError, ok := r.AdditionalResources["error"].(error)
3328
if !ok {
3429
return result, fmt.Errorf("Missing required CCAM field 'error'")

pkg/investigations/ccam/ccam_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func TestEvaluateRandomError(t *testing.T) {
1616
OcmClient: nil,
1717
PdClient: nil,
1818
AdditionalResources: map[string]interface{}{
19-
"alertType": "",
20-
"error": errors.New("timeout"),
19+
"error": errors.New("timeout"),
2120
},
2221
}
2322
_, err := Investigate(&input)

pkg/investigations/chgm/chgm.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
)
2323

2424
var (
25-
investigationName = "ClusterHasGoneMissing"
26-
2725
chgmSL = ocm.ServiceLog{
2826
Severity: "Critical",
2927
Summary: "Action required: cluster not checking in",
@@ -40,7 +38,7 @@ var (
4038

4139
// Investigate runs the investigation for a triggered chgm pagerduty event
4240
func Investigate(r *investigation.Resources) (investigation.InvestigationResult, error) {
43-
result := investigation.InvestigationResult{InvestigationName: investigationName}
41+
result := investigation.InvestigationResult{}
4442
notes := notewriter.New("CHGM", logging.RawLogger)
4543

4644
// 1. Check if the user stopped instances

pkg/investigations/cpd/cpd.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ import (
1010
"github.com/openshift/configuration-anomaly-detection/pkg/ocm"
1111
)
1212

13-
var (
14-
investigationName = "ClusterProvisioningDelay"
15-
// https://raw.githubusercontent.com/openshift/managed-notifications/master/osd/aws/InstallFailed_NoRouteToInternet.json
16-
byovpcRoutingSL = &ocm.ServiceLog{Severity: "Major", Summary: "Installation blocked: Missing route to internet", Description: "Your cluster's installation is blocked because of the missing route to internet in the route table(s) associated with the supplied subnet(s) for cluster installation. Please review and validate the routes by following documentation and re-install the cluster: https://docs.openshift.com/container-platform/latest/installing/installing_aws/installing-aws-vpc.html#installation-custom-aws-vpc-requirements_installing-aws-vpc.", InternalOnly: false, ServiceName: "SREManualAction"}
17-
)
13+
// https://raw.githubusercontent.com/openshift/managed-notifications/master/osd/aws/InstallFailed_NoRouteToInternet.json
14+
var byovpcRoutingSL = &ocm.ServiceLog{Severity: "Major", Summary: "Installation blocked: Missing route to internet", Description: "Your cluster's installation is blocked because of the missing route to internet in the route table(s) associated with the supplied subnet(s) for cluster installation. Please review and validate the routes by following documentation and re-install the cluster: https://docs.openshift.com/container-platform/latest/installing/installing_aws/installing-aws-vpc.html#installation-custom-aws-vpc-requirements_installing-aws-vpc.", InternalOnly: false, ServiceName: "SREManualAction"}
1815

1916
// Investigate runs the investigation for a triggered CPD pagerduty event
2017
// Currently what this investigation does is:
@@ -27,7 +24,7 @@ var (
2724
// The reasoning for this is that we don't fully trust network verifier yet.
2825
// In the future, we want to automate service logs based on the network verifier output.
2926
func Investigate(r *investigation.Resources) (investigation.InvestigationResult, error) {
30-
result := investigation.InvestigationResult{InvestigationName: investigationName}
27+
result := investigation.InvestigationResult{}
3128
notes := notewriter.New("CPD", logging.RawLogger)
3229

3330
if r.Cluster.Status().State() == "ready" {

pkg/investigations/investigation.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type InvestigationStep struct {
1515
}
1616

1717
type InvestigationResult struct {
18-
InvestigationName string
1918
LimitedSupportSet InvestigationStep
2019
ServiceLogPrepared InvestigationStep
2120
ServiceLogSent InvestigationStep

0 commit comments

Comments
 (0)