Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rakesh-garimella committed Jan 31, 2024
1 parent d347c83 commit e86025a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions internal/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ func CommonMessageFor(reason string) string {
}

func FetchReasonFromAlert(alert prometheus.Alerts) string {
if reason, found := alertMap[alert.Name]; found {
//fmt.Printf("PipelineName: %v\n", alert.PipelineInfo)
return reason
}
return ""
}

func MessageForAlerts(alert prometheus.Alerts) string {
reason := FetchReasonFromAlert(alert)
if reason == "" {
return ""
}
if reasonMsg, found := alertMap[alert.Name]; found {
fmt.Printf("PipelineName: %v\n", alert.PipelineInfo)
return strings.Replace(reasonMsg, "pipelineName", alert.PipelineInfo, 1)
Expand Down
15 changes: 13 additions & 2 deletions internal/reconciler/metricpipeline/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ func (r *Reconciler) setMetricFlowHealthCondition(pipeline *telemetryv1alpha1.Me
status = metav1.ConditionFalse
reason = conditions.FetchReasonFromAlert(alert)
}
msg := conditions.MessageForAlerts(alert)

fmt.Printf("Status is: %v, Reason: %v\n", status, reason)
fmt.Printf("Status is: %v, Reason: %v, msg: %v\n", status, reason)

meta.SetStatusCondition(&pipeline.Status.Conditions, newCondition(conditions.TypeMetricFlowHealthy, reason, status, pipeline.Generation))
meta.SetStatusCondition(&pipeline.Status.Conditions, newConditionForAlerts(conditions.TypeMetricFlowHealthy, reason, status, msg, pipeline.Generation))

Check failure on line 118 in internal/reconciler/metricpipeline/status.go

View workflow job for this annotation

GitHub Actions / coverage

cannot use status (variable of type "k8s.io/apimachinery/pkg/apis/meta/v1".ConditionStatus) as string value in argument to newConditionForAlerts

Check failure on line 118 in internal/reconciler/metricpipeline/status.go

View workflow job for this annotation

GitHub Actions / coverage

cannot use msg (variable of type string) as "k8s.io/apimachinery/pkg/apis/meta/v1".ConditionStatus value in argument to newConditionForAlerts

Check failure on line 118 in internal/reconciler/metricpipeline/status.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use status (variable of type "k8s.io/apimachinery/pkg/apis/meta/v1".ConditionStatus) as string value in argument to newConditionForAlerts

Check failure on line 118 in internal/reconciler/metricpipeline/status.go

View workflow job for this annotation

GitHub Actions / unit-tests

cannot use msg (variable of type string) as "k8s.io/apimachinery/pkg/apis/meta/v1".ConditionStatus value in argument to newConditionForAlerts
}

func newCondition(condType, reason string, status metav1.ConditionStatus, generation int64) metav1.Condition {
Expand All @@ -126,3 +127,13 @@ func newCondition(condType, reason string, status metav1.ConditionStatus, genera
ObservedGeneration: generation,
}
}

func newConditionForAlerts(condType, reason, msg string, status metav1.ConditionStatus, generation int64) metav1.Condition {
return metav1.Condition{
Type: condType,
Status: status,
Reason: reason,
Message: msg,
ObservedGeneration: generation,
}
}

0 comments on commit e86025a

Please sign in to comment.