Commit b0259b6c authored by Adam Harrison's avatar Adam Harrison
Browse files

Remove obsolete waitForDrain implementation

`kubectl drain` now ignores undrainable things and waits for
termination, so we no longer have to do that ourselves.
parent 156e9a1c
......@@ -171,40 +171,6 @@ func uncordon(nodeID string) {
}
}
func waitForDrain(client *kubernetes.Clientset, nodeID string) {
for {
var unterminated int
namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{})
if err != nil {
log.Fatalf("Error waiting for drain: %v", err)
}
for _, namespace := range namespaces.Items {
drainCandidates := metav1.ListOptions{LabelSelector: "ignore_on_drain!=true"}
pods, err := client.CoreV1().Pods(namespace.ObjectMeta.Name).List(drainCandidates)
if err != nil {
log.Fatalf("Error waiting for drain: %v", err)
}
for _, pod := range pods.Items {
if pod.Spec.NodeName == nodeID &&
pod.Status.Phase != "Succeeded" &&
pod.Status.Phase != "Failed" {
unterminated++
}
}
}
if unterminated == 0 {
return
}
log.Infof("Waiting for %d pods to terminate", unterminated)
time.Sleep(time.Minute)
}
}
func commandReboot(nodeID string) {
log.Infof("Commanding reboot")
......@@ -271,7 +237,6 @@ func rebootAsRequired(nodeID string) {
if acquire(lock, &nodeMeta) {
if !nodeMeta.Unschedulable {
drain(nodeID)
waitForDrain(client, nodeID)
}
commandReboot(nodeID)
for {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment