@@ -960,10 +960,10 @@ func (dsc *DaemonSetsController) manage(ds *apps.DaemonSet, nodeList []*v1.Node,
960
960
failedPodsObserved += failedPodsObservedOnNode
961
961
}
962
962
963
- // Remove pods assigned to not existing nodes when daemonset pods are scheduled by default scheduler.
963
+ // Remove unscheduled pods assigned to not existing nodes when daemonset pods are scheduled by scheduler.
964
964
// If node doesn't exist then pods are never scheduled and can't be deleted by PodGCController.
965
965
if utilfeature .DefaultFeatureGate .Enabled (features .ScheduleDaemonSetPods ) {
966
- podsToDelete = append (podsToDelete , getPodsWithoutNode (nodeList , nodeToDaemonPods )... )
966
+ podsToDelete = append (podsToDelete , getUnscheduledPodsWithoutNode (nodeList , nodeToDaemonPods )... )
967
967
}
968
968
969
969
// Label new pods using the hash label value of the current history when creating them
@@ -1527,8 +1527,9 @@ func failedPodsBackoffKey(ds *apps.DaemonSet, nodeName string) string {
1527
1527
return fmt .Sprintf ("%s/%d/%s" , ds .UID , ds .Status .ObservedGeneration , nodeName )
1528
1528
}
1529
1529
1530
- // getPodsWithoutNode returns list of pods assigned to not existing nodes.
1531
- func getPodsWithoutNode (runningNodesList []* v1.Node , nodeToDaemonPods map [string ][]* v1.Pod ) []string {
1530
+ // getUnscheduledPodsWithoutNode returns list of unscheduled pods assigned to not existing nodes.
1531
+ // Returned pods can't be deleted by PodGCController so they should be deleted by DaemonSetController.
1532
+ func getUnscheduledPodsWithoutNode (runningNodesList []* v1.Node , nodeToDaemonPods map [string ][]* v1.Pod ) []string {
1532
1533
var results []string
1533
1534
isNodeRunning := make (map [string ]bool )
1534
1535
for _ , node := range runningNodesList {
@@ -1537,7 +1538,9 @@ func getPodsWithoutNode(runningNodesList []*v1.Node, nodeToDaemonPods map[string
1537
1538
for n , pods := range nodeToDaemonPods {
1538
1539
if ! isNodeRunning [n ] {
1539
1540
for _ , pod := range pods {
1540
- results = append (results , pod .Name )
1541
+ if len (pod .Spec .NodeName ) == 0 {
1542
+ results = append (results , pod .Name )
1543
+ }
1541
1544
}
1542
1545
}
1543
1546
}
0 commit comments