Skip to content

Commit

Permalink
fix: error message on Canary CRD status
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Dec 17, 2024
1 parent 513be23 commit 50cf0f7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/jobs/canary/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [

var checkStatus = make(map[string]*v1.CheckStatus)
var duration int64
var messages, errors []string
var messages, errorMsgs []string
var failEvents []string
var msg, errorMsg string
var msg string
var status v1.CanaryStatusCondition
var lastTransitionedTime *metav1.Time
var highestLatency float64
Expand Down Expand Up @@ -87,10 +87,9 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [
} else if len(messages) > 1 {
msg = fmt.Sprintf("%s, (%d more)", messages[0], len(messages)-1)
}
if len(errors) == 1 {
errorMsg = errors[0]
} else if len(errors) > 1 {
errorMsg = fmt.Sprintf("%s, (%d more)", errors[0], len(errors)-1)

if result.Error != "" {
errorMsgs = append(errorMsgs, result.Error)
}

if result.Pass {
Expand All @@ -105,13 +104,20 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [
}
}

var errMsg string
if len(errorMsgs) == 1 {
errMsg = errorMsgs[0]
} else if len(errorMsgs) > 1 {
errMsg = fmt.Sprintf("%s, (%d more)", errorMsgs[0], len(errorMsgs)-1)
}

payload := CanaryStatusPayload{
Status: status,
CheckStatus: checkStatus,
FailEvents: failEvents,
LastTransitionedTime: lastTransitionedTime,
Message: msg,
ErrorMessage: errorMsg,
ErrorMessage: errMsg,
Uptime: uptimeAgg.String(),
Latency: utils.Age(time.Duration(highestLatency) * time.Millisecond),
NamespacedName: canary.GetNamespacedName(),
Expand Down

0 comments on commit 50cf0f7

Please sign in to comment.