@@ -190,7 +190,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
190190 // Log and emit success event.
191191 if conditions .IsReady (obj ) {
192192 msg := fmt .Sprintf ("Reconciliation finished in %s, next run in %s" ,
193- time . Since (reconcileStart ). String ( ),
193+ formatDurationSince (reconcileStart ),
194194 obj .Spec .Interval .Duration .String ())
195195 log .Info (msg , "revision" , obj .Status .LastAttemptedRevision )
196196 r .event (obj , obj .Status .LastAppliedRevision , eventv1 .EventSeverityInfo , msg ,
@@ -276,7 +276,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
276276 // Broadcast the reconciliation failure and requeue at the specified retry interval.
277277 if reconcileErr != nil {
278278 log .Error (reconcileErr , fmt .Sprintf ("Reconciliation failed after %s, next try in %s" ,
279- time . Since (reconcileStart ). String ( ),
279+ formatDurationSince (reconcileStart ),
280280 obj .GetRetryInterval ().String ()),
281281 "revision" ,
282282 artifactSource .GetArtifact ().Revision )
@@ -904,11 +904,11 @@ func (r *KustomizationReconciler) checkHealth(ctx context.Context,
904904 }); err != nil {
905905 conditions .MarkFalse (obj , meta .ReadyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
906906 conditions .MarkFalse (obj , kustomizev1 .HealthyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
907- return fmt .Errorf ("health check failed after %s: %w" , time . Since (checkStart ). String ( ), err )
907+ return fmt .Errorf ("health check failed after %s: %w" , formatDurationSince (checkStart ), err )
908908 }
909909
910910 // Emit recovery event if the previous health check failed.
911- msg := fmt .Sprintf ("Health check passed in %s" , time . Since (checkStart ). String ( ))
911+ msg := fmt .Sprintf ("Health check passed in %s" , formatDurationSince (checkStart ))
912912 if ! wasHealthy || (isNewRevision && drifted ) {
913913 r .event (obj , revision , eventv1 .EventSeverityInfo , msg , nil )
914914 }
@@ -1101,3 +1101,11 @@ func (r *KustomizationReconciler) patch(ctx context.Context,
11011101
11021102 return nil
11031103}
1104+
1105+ func formatDurationSince (t time.Time ) string {
1106+ if (time .Since (t ) < time .Second ) {
1107+ return time .Since (t ).Round (time .Millisecond ).String ()
1108+ } else {
1109+ return time .Since (t ).Round (time .Second ).String ()
1110+ }
1111+ }
0 commit comments