@@ -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 )
@@ -876,11 +876,11 @@ func (r *KustomizationReconciler) checkHealth(ctx context.Context,
876876 }); err != nil {
877877 conditions .MarkFalse (obj , meta .ReadyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
878878 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 )
880880 }
881881
882882 // 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 ))
884884 if ! wasHealthy || (isNewRevision && drifted ) {
885885 r .event (obj , revision , eventv1 .EventSeverityInfo , msg , nil )
886886 }
@@ -1074,3 +1074,7 @@ func (r *KustomizationReconciler) patch(ctx context.Context,
10741074
10751075 return nil
10761076}
1077+
1078+ func formatDurationSince (t time.Time ) string {
1079+ return time .Since (t ).Round (time .Second ).String ()
1080+ }
0 commit comments