From ec2497d2677c887ea9a7b55b0e6f936b7be6a0ce Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Wed, 12 Jan 2022 19:58:10 +0000 Subject: [PATCH] Fix to improper formatting of UnhealthyRange Signed-off-by: killianmuldoon --- .../machinehealthcheck_controller.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go b/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go index ed9bcf5bf4ab..9343484b5429 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_controller.go @@ -270,14 +270,14 @@ func (r *Reconciler) reconcile(ctx context.Context, logger logr.Logger, cluster Status: corev1.ConditionFalse, Severity: clusterv1.ConditionSeverityWarning, Reason: clusterv1.TooManyUnhealthyReason, - Message: message, + Message: formatPercentSign(message), }) r.recorder.Eventf( m, corev1.EventTypeWarning, EventRemediationRestricted, - message, + formatPercentSign(message), ) errList := []error{} for _, t := range append(healthy, unhealthy...) { @@ -659,3 +659,11 @@ func (r *Reconciler) externalRemediationRequestExists(ctx context.Context, m *cl } return remediationReq != nil } + +func formatPercentSign(message string) string { + var out string + if strings.Contains(message, "%") { + out = strings.Replace(message, "%", "%%", -1) + } + return out +}