Deleting pods assigned to not existing nodes only if

ScheduleDaemonSetPods is enabled.
This commit is contained in:
Krzysztof Jastrzebski
2019-01-31 20:26:19 +01:00
parent 8f1082c6af
commit 0087af78e2
2 changed files with 11 additions and 5 deletions

View File

@@ -964,8 +964,11 @@ func (dsc *DaemonSetsController) manage(ds *apps.DaemonSet, hash string) error {
failedPodsObserved += failedPodsObservedOnNode
}
// Remove pods assigned to not existing nodes.
podsToDelete = append(podsToDelete, getPodsWithoutNode(nodeList, nodeToDaemonPods)...)
// Remove pods assigned to not existing nodes when daemonset pods are scheduled by default scheduler.
// If node doesn't exist then pods are never scheduled and can't be deleted by PodGCController.
if utilfeature.DefaultFeatureGate.Enabled(features.ScheduleDaemonSetPods) {
podsToDelete = append(podsToDelete, getPodsWithoutNode(nodeList, nodeToDaemonPods)...)
}
// Label new pods using the hash label value of the current history when creating them
if err = dsc.syncNodes(ds, podsToDelete, nodesNeedingDaemonPods, hash); err != nil {
@@ -1529,8 +1532,7 @@ func failedPodsBackoffKey(ds *apps.DaemonSet, nodeName string) string {
}
// getPodsWithoutNode returns list of pods assigned to not existing nodes.
func getPodsWithoutNode(
runningNodesList []*v1.Node, nodeToDaemonPods map[string][]*v1.Pod) []string {
func getPodsWithoutNode(runningNodesList []*v1.Node, nodeToDaemonPods map[string][]*v1.Pod) []string {
var results []string
isNodeRunning := make(map[string]bool)
for _, node := range runningNodesList {