Delete pods assigned to not existing nodes.
This commit is contained in:
@@ -964,6 +964,9 @@ 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)...)
|
||||
|
||||
// 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 {
|
||||
return err
|
||||
@@ -1524,3 +1527,21 @@ func (o podByCreationTimestampAndPhase) Less(i, j int) bool {
|
||||
func failedPodsBackoffKey(ds *apps.DaemonSet, nodeName string) string {
|
||||
return fmt.Sprintf("%s/%d/%s", ds.UID, ds.Status.ObservedGeneration, nodeName)
|
||||
}
|
||||
|
||||
// getPodsWithoutNode returns list of pods assigned to not existing nodes.
|
||||
func getPodsWithoutNode(
|
||||
runningNodesList []*v1.Node, nodeToDaemonPods map[string][]*v1.Pod) []string {
|
||||
var results []string
|
||||
isNodeRunning := make(map[string]bool)
|
||||
for _, node := range runningNodesList {
|
||||
isNodeRunning[node.Name] = true
|
||||
}
|
||||
for n, pods := range nodeToDaemonPods {
|
||||
if !isNodeRunning[n] {
|
||||
for _, pod := range pods {
|
||||
results = append(results, pod.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
Reference in New Issue
Block a user