From 1380ec6ffd74a6ea793a54ff27295cc62e98a58c Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Thu, 7 May 2026 18:18:43 -0400 Subject: [PATCH] fix: handle not-found error in nodeagent DaemonSet deletion When NodeAgent is disabled, a TOCTOU race condition can occur between concurrent reconciliation loops: one loop deletes the DaemonSet while another is between Get() and Delete(), causing Delete() to fail with "not found". This error was incorrectly treated as a failure, causing DPA to transition to Reconciled=False. Treat "not found" errors during DaemonSet deletion as success since the desired state (DaemonSet absent) is already achieved. This matches the pattern already used by other Delete calls in the same file (lines 232 and 770). Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy Signed-off-by: Tiger Kaovilai --- internal/controller/nodeagent.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/controller/nodeagent.go b/internal/controller/nodeagent.go index e78e830309..44db2a475a 100644 --- a/internal/controller/nodeagent.go +++ b/internal/controller/nodeagent.go @@ -276,6 +276,9 @@ func (r *DataProtectionApplicationReconciler) ReconcileNodeAgentDaemonset(log lo // no errors means there is already an existing DaemonSet. // TODO: Check if NodeAgent is in use, a backup is running, so don't blindly delete NodeAgent. if err := r.Delete(deleteContext, ds, &client.DeleteOptions{PropagationPolicy: ptr.To(metav1.DeletePropagationForeground)}); err != nil { + if errors.IsNotFound(err) { + return true, nil + } // TODO: Come back and fix event recording to be consistent r.EventRecorder.Event(ds, corev1.EventTypeNormal, "DeleteDaemonSetFailed", "Got DaemonSet to delete but could not delete err:"+err.Error()) return false, err