Move test for node schedulability

Test for schedulability immediately prior to each reboot check instead
of once at startup, thereby accomodating external changes to this value
during the lifetime of the daemon.
This commit is contained in:
Adam Harrison
2017-08-03 08:53:24 +01:00
parent 8aafc8905e
commit 55ba779702

View File

@@ -220,24 +220,26 @@ func root(cmd *cobra.Command, args []string) {
uncordon(nodeID)
}
release(lock)
} else {
node, err := client.CoreV1().Nodes().Get(nodeID)
if err != nil {
log.Fatal(err)
}
nodeMeta.Unschedulable = node.Spec.Unschedulable
}
source := rand.NewSource(time.Now().UnixNano())
tick := delaytick.New(source, time.Minute*time.Duration(period))
for _ = range tick {
if rebootRequired() && !rebootBlocked() && acquire(lock, &nodeMeta) {
if !nodeMeta.Unschedulable {
drain(nodeID)
waitForDrain(client, nodeID)
if rebootRequired() && !rebootBlocked() {
node, err := client.CoreV1().Nodes().Get(nodeID)
if err != nil {
log.Fatal(err)
}
nodeMeta.Unschedulable = node.Spec.Unschedulable
if acquire(lock, &nodeMeta) {
if !nodeMeta.Unschedulable {
drain(nodeID)
waitForDrain(client, nodeID)
}
reboot()
break
}
reboot()
break
}
}