From 976f21b393fa7d32d5cadcd1cfc0b6e819b5c636 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Tue, 17 Dec 2024 14:37:13 +0545 Subject: [PATCH] fix: canary CRD message --- pkg/jobs/canary/status.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/jobs/canary/status.go b/pkg/jobs/canary/status.go index 6b4626e11..6726ec7b5 100644 --- a/pkg/jobs/canary/status.go +++ b/pkg/jobs/canary/status.go @@ -31,7 +31,6 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [ var duration int64 var messages, errorMsgs []string var failEvents []string - var msg string var status v1.CanaryStatusCondition var lastTransitionedTime *metav1.Time var highestLatency float64 @@ -81,11 +80,8 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [ lastTransitionedTime = &metav1.Time{Time: transitionTime} } - // Update status message - if len(messages) == 1 { - msg = messages[0] - } else if len(messages) > 1 { - msg = fmt.Sprintf("%s, (%d more)", messages[0], len(messages)-1) + if result.Message != "" { + messages = append(messages, result.Message) } if result.Error != "" { @@ -111,6 +107,13 @@ func UpdateCanaryStatusAndEvent(ctx context.Context, canary v1.Canary, results [ errMsg = fmt.Sprintf("%s, (%d more)", errorMsgs[0], len(errorMsgs)-1) } + var msg string + if len(messages) == 1 { + msg = messages[0] + } else if len(messages) > 1 { + msg = fmt.Sprintf("%s, (%d more)", messages[0], len(messages)-1) + } + payload := CanaryStatusPayload{ Status: status, CheckStatus: checkStatus,