@@ -188,7 +188,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
188
188
// Log and emit success event.
189
189
if conditions .IsReady (obj ) {
190
190
msg := fmt .Sprintf ("Reconciliation finished in %s, next run in %s" ,
191
- time . Since (reconcileStart ). String ( ),
191
+ formatDurationSince (reconcileStart ),
192
192
obj .Spec .Interval .Duration .String ())
193
193
log .Info (msg , "revision" , obj .Status .LastAttemptedRevision )
194
194
r .event (obj , obj .Status .LastAppliedRevision , eventv1 .EventSeverityInfo , msg ,
@@ -274,7 +274,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
274
274
// Broadcast the reconciliation failure and requeue at the specified retry interval.
275
275
if reconcileErr != nil {
276
276
log .Error (reconcileErr , fmt .Sprintf ("Reconciliation failed after %s, next try in %s" ,
277
- time . Since (reconcileStart ). String ( ),
277
+ formatDurationSince (reconcileStart ),
278
278
obj .GetRetryInterval ().String ()),
279
279
"revision" ,
280
280
artifactSource .GetArtifact ().Revision )
@@ -896,11 +896,11 @@ func (r *KustomizationReconciler) checkHealth(ctx context.Context,
896
896
}); err != nil {
897
897
conditions .MarkFalse (obj , meta .ReadyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
898
898
conditions .MarkFalse (obj , kustomizev1 .HealthyCondition , kustomizev1 .HealthCheckFailedReason , err .Error ())
899
- return fmt .Errorf ("health check failed after %s: %w" , time . Since (checkStart ). String ( ), err )
899
+ return fmt .Errorf ("health check failed after %s: %w" , formatDurationSince (checkStart ), err )
900
900
}
901
901
902
902
// Emit recovery event if the previous health check failed.
903
- msg := fmt .Sprintf ("Health check passed in %s" , time . Since (checkStart ). String ( ))
903
+ msg := fmt .Sprintf ("Health check passed in %s" , formatDurationSince (checkStart ))
904
904
if ! wasHealthy || (isNewRevision && drifted ) {
905
905
r .event (obj , revision , eventv1 .EventSeverityInfo , msg , nil )
906
906
}
@@ -1094,3 +1094,7 @@ func (r *KustomizationReconciler) patch(ctx context.Context,
1094
1094
1095
1095
return nil
1096
1096
}
1097
+
1098
+ func formatDurationSince (t time.Time ) string {
1099
+ return time .Since (t ).Round (time .Second ).String ()
1100
+ }
0 commit comments