diff --git a/internal/controller/nodemaintenance_controller.go b/internal/controller/nodemaintenance_controller.go index c55da0a..ffb68ae 100644 --- a/internal/controller/nodemaintenance_controller.go +++ b/internal/controller/nodemaintenance_controller.go @@ -535,9 +535,8 @@ func (r *NodeMaintenanceReconciler) handleReadyState(ctx context.Context, reqLog return res, err } - // set ready-time annotation - if !metav1.HasAnnotation(nm.ObjectMeta, ReadyTimeAnnotation) || - nm.Annotations[ReadyTimeAnnotation] == "" { + // set ready-time annotation if not present on not set + if nm.Annotations[ReadyTimeAnnotation] == "" { metav1.SetMetaDataAnnotation(&nm.ObjectMeta, ReadyTimeAnnotation, time.Now().UTC().Format(time.RFC3339)) err := r.Update(ctx, nm) if err != nil { diff --git a/internal/podcompletion/podcompletion.go b/internal/podcompletion/podcompletion.go index 3f29160..7843565 100644 --- a/internal/podcompletion/podcompletion.go +++ b/internal/podcompletion/podcompletion.go @@ -63,9 +63,8 @@ func (p *podCompletionHandler) HandlePodCompletion(ctx context.Context, reqLog l var err error var startTime time.Time - if !metav1.HasAnnotation(nm.ObjectMeta, WaitForPodCompletionStartAnnot) || - nm.Annotations[WaitForPodCompletionStartAnnot] == "" { - // set waitForPodCompletion time annotation + if nm.Annotations[WaitForPodCompletionStartAnnot] == "" { + // set waitForPodCompletion time annotation if not set or empty startTime = time.Now().UTC() metav1.SetMetaDataAnnotation(&nm.ObjectMeta, WaitForPodCompletionStartAnnot, startTime.Format(time.RFC3339)) err = p.k8sclient.Update(ctx, nm) diff --git a/internal/podcompletion/podcompletion_test.go b/internal/podcompletion/podcompletion_test.go index 60a64fd..364402f 100644 --- a/internal/podcompletion/podcompletion_test.go +++ b/internal/podcompletion/podcompletion_test.go @@ -77,7 +77,6 @@ var _ = Describe("podcompletion tests", func() { Expect(fakeClient.Get(testCtx, client.ObjectKeyFromObject(nm), nm)).ToNot(HaveOccurred()) Expect(nm.Status.WaitForCompletion).To(Equal([]string{"default/test-pod"})) - Expect(metav1.HasAnnotation(nm.ObjectMeta, podcompletion.WaitForPodCompletionStartAnnot)).To(BeTrue()) t1, e := time.Parse(time.RFC3339, nm.Annotations[podcompletion.WaitForPodCompletionStartAnnot]) Expect(e).ToNot(HaveOccurred())