Skip to content

Commit 47d005e

Browse files
committed
fix: prevent CSI node from deleting DaemonSet mount pods
DaemonSet mount pods should be managed by the DaemonSet controller, not deleted by the CSI node reconciler when they have no references. The CSI node should only add/remove client references (connect/disconnect). This fixes the recreation loop where CSI nodes were continuously trying to delete DaemonSet pods that had no references, causing the reconciler to report errors every 5 seconds. Added isDaemonSetPod() helper to identify DaemonSet-managed pods by: - Checking OwnerReferences for DaemonSet ownership - Checking pod name pattern for "-mount-ds-" suffix (backward compatibility)
1 parent e18b5a6 commit 47d005e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pkg/controller/pod_driver.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@ func getPodStatus(pod *corev1.Pod) podStatus {
180180
return podPending
181181
}
182182

183+
// isDaemonSetPod checks if a pod is managed by a DaemonSet
184+
func isDaemonSetPod(pod *corev1.Pod) bool {
185+
// Check if pod is owned by a DaemonSet
186+
for _, owner := range pod.OwnerReferences {
187+
if owner.Kind == "DaemonSet" {
188+
return true
189+
}
190+
}
191+
// Also check if pod name matches DaemonSet pattern (for backward compatibility)
192+
// DaemonSet mount pods have names like "juicefs-<uniqueid>-mount-ds-<suffix>"
193+
if strings.Contains(pod.Name, "-mount-ds-") {
194+
return true
195+
}
196+
return false
197+
}
198+
183199
// checkAnnotations
184200
// 1. check refs in mount pod annotation
185201
// 2. delete ref that target pod is not found
@@ -227,6 +243,14 @@ func (p *PodDriver) checkAnnotations(ctx context.Context, pod *corev1.Pod) error
227243
}
228244
}
229245
if existTargets == 0 && pod.DeletionTimestamp == nil {
246+
// Check if this is a DaemonSet pod - they should not be deleted when they have no refs
247+
// DaemonSet pods are managed by the DaemonSet controller
248+
if isDaemonSetPod(pod) {
249+
// Skip DaemonSet pods - they're managed by the DaemonSet controller
250+
// No need to log or return error, just skip processing
251+
return nil
252+
}
253+
230254
var shouldDelay bool
231255
shouldDelay, err := resource.ShouldDelay(ctx, pod, p.Client)
232256
if err != nil {

0 commit comments

Comments
 (0)