@@ -190,7 +190,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
190
190
// Log and emit success event.
191
191
if conditions .IsReady (obj ) {
192
192
msg := fmt .Sprintf ("Reconciliation finished in %s, next run in %s" ,
193
- time . Since (reconcileStart ). String ( ),
193
+ formatDurationSince (reconcileStart ),
194
194
obj .Spec .Interval .Duration .String ())
195
195
log .Info (msg , "revision" , obj .Status .LastAttemptedRevision )
196
196
r .event (obj , obj .Status .LastAppliedRevision , eventv1 .EventSeverityInfo , msg ,
@@ -276,7 +276,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
276
276
// Broadcast the reconciliation failure and requeue at the specified retry interval.
277
277
if reconcileErr != nil {
278
278
log .Error (reconcileErr , fmt .Sprintf ("Reconciliation failed after %s, next try in %s" ,
279
- time . Since (reconcileStart ). String ( ),
279
+ formatDurationSince (reconcileStart ),
280
280
obj .GetRetryInterval ().String ()),
281
281
"revision" ,
282
282
artifactSource .GetArtifact ().Revision )
@@ -876,11 +876,11 @@ func (r *KustomizationReconciler) checkHealth(ctx context.Context,
876
876
}); err != nil {
877
877
conditions .MarkFalse (obj , meta .ReadyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
878
878
conditions .MarkFalse (obj , kustomizev1 .HealthyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
879
- return fmt .Errorf ("Health check failed after %s: %w" , time . Since (checkStart ). String ( ), err )
879
+ return fmt .Errorf ("Health check failed after %s: %w" , formatDurationSince (checkStart ), err )
880
880
}
881
881
882
882
// Emit recovery event if the previous health check failed.
883
- msg := fmt .Sprintf ("Health check passed in %s" , time . Since (checkStart ). String ( ))
883
+ msg := fmt .Sprintf ("Health check passed in %s" , formatDurationSince (checkStart ))
884
884
if ! wasHealthy || (isNewRevision && drifted ) {
885
885
r .event (obj , revision , eventv1 .EventSeverityInfo , msg , nil )
886
886
}
@@ -1074,3 +1074,7 @@ func (r *KustomizationReconciler) patch(ctx context.Context,
1074
1074
1075
1075
return nil
1076
1076
}
1077
+
1078
+ func formatDurationSince (t time.Time ) string {
1079
+ return time .Since (t ).Round (time .Second ).String ()
1080
+ }
0 commit comments