|
|
|
@@ -641,7 +641,7 @@ func (dsc *DaemonSetsController) addNode(obj interface{}) {
|
|
|
|
|
}
|
|
|
|
|
node := obj.(*v1.Node)
|
|
|
|
|
for _, ds := range dsList {
|
|
|
|
|
if shouldRun, _ := dsc.nodeShouldRunDaemonPod(node, ds); shouldRun {
|
|
|
|
|
if shouldRun, _ := NodeShouldRunDaemonPod(node, ds); shouldRun {
|
|
|
|
|
dsc.enqueueDaemonSet(ds)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -699,8 +699,8 @@ func (dsc *DaemonSetsController) updateNode(old, cur interface{}) {
|
|
|
|
|
}
|
|
|
|
|
// TODO: it'd be nice to pass a hint with these enqueues, so that each ds would only examine the added node (unless it has other work to do, too).
|
|
|
|
|
for _, ds := range dsList {
|
|
|
|
|
oldShouldRun, oldShouldContinueRunning := dsc.nodeShouldRunDaemonPod(oldNode, ds)
|
|
|
|
|
currentShouldRun, currentShouldContinueRunning := dsc.nodeShouldRunDaemonPod(curNode, ds)
|
|
|
|
|
oldShouldRun, oldShouldContinueRunning := NodeShouldRunDaemonPod(oldNode, ds)
|
|
|
|
|
currentShouldRun, currentShouldContinueRunning := NodeShouldRunDaemonPod(curNode, ds)
|
|
|
|
|
if (oldShouldRun != currentShouldRun) || (oldShouldContinueRunning != currentShouldContinueRunning) {
|
|
|
|
|
dsc.enqueueDaemonSet(ds)
|
|
|
|
|
}
|
|
|
|
@@ -798,7 +798,7 @@ func (dsc *DaemonSetsController) podsShouldBeOnNode(
|
|
|
|
|
hash string,
|
|
|
|
|
) (nodesNeedingDaemonPods, podsToDelete []string) {
|
|
|
|
|
|
|
|
|
|
shouldRun, shouldContinueRunning := dsc.nodeShouldRunDaemonPod(node, ds)
|
|
|
|
|
shouldRun, shouldContinueRunning := NodeShouldRunDaemonPod(node, ds)
|
|
|
|
|
daemonPods, exists := nodeToDaemonPods[node.Name]
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
@@ -1118,7 +1118,7 @@ func (dsc *DaemonSetsController) updateDaemonSetStatus(ctx context.Context, ds *
|
|
|
|
|
var desiredNumberScheduled, currentNumberScheduled, numberMisscheduled, numberReady, updatedNumberScheduled, numberAvailable int
|
|
|
|
|
now := dsc.failedPodsBackoff.Clock.Now()
|
|
|
|
|
for _, node := range nodeList {
|
|
|
|
|
shouldRun, _ := dsc.nodeShouldRunDaemonPod(node, ds)
|
|
|
|
|
shouldRun, _ := NodeShouldRunDaemonPod(node, ds)
|
|
|
|
|
scheduled := len(nodeToDaemonPods[node.Name]) > 0
|
|
|
|
|
|
|
|
|
|
if shouldRun {
|
|
|
|
@@ -1254,7 +1254,7 @@ func (dsc *DaemonSetsController) syncDaemonSet(ctx context.Context, key string)
|
|
|
|
|
return dsc.updateDaemonSetStatus(ctx, ds, nodeList, hash, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// nodeShouldRunDaemonPod checks a set of preconditions against a (node,daemonset) and returns a
|
|
|
|
|
// NodeShouldRunDaemonPod checks a set of preconditions against a (node,daemonset) and returns a
|
|
|
|
|
// summary. Returned booleans are:
|
|
|
|
|
// * shouldRun:
|
|
|
|
|
// Returns true when a daemonset should run on the node if a daemonset pod is not already
|
|
|
|
@@ -1262,7 +1262,7 @@ func (dsc *DaemonSetsController) syncDaemonSet(ctx context.Context, key string)
|
|
|
|
|
// * shouldContinueRunning:
|
|
|
|
|
// Returns true when a daemonset should continue running on a node if a daemonset pod is already
|
|
|
|
|
// running on that node.
|
|
|
|
|
func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *apps.DaemonSet) (bool, bool) {
|
|
|
|
|
func NodeShouldRunDaemonPod(node *v1.Node, ds *apps.DaemonSet) (bool, bool) {
|
|
|
|
|
pod := NewPod(ds, node.Name)
|
|
|
|
|
|
|
|
|
|
// If the daemon set specifies a node name, check that it matches with node.Name.
|
|
|
|
@@ -1271,7 +1271,7 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *apps.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
taints := node.Spec.Taints
|
|
|
|
|
fitsNodeName, fitsNodeAffinity, fitsTaints := Predicates(pod, node, taints)
|
|
|
|
|
fitsNodeName, fitsNodeAffinity, fitsTaints := predicates(pod, node, taints)
|
|
|
|
|
if !fitsNodeName || !fitsNodeAffinity {
|
|
|
|
|
return false, false
|
|
|
|
|
}
|
|
|
|
@@ -1287,8 +1287,8 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *apps.
|
|
|
|
|
return true, true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Predicates checks if a DaemonSet's pod can run on a node.
|
|
|
|
|
func Predicates(pod *v1.Pod, node *v1.Node, taints []v1.Taint) (fitsNodeName, fitsNodeAffinity, fitsTaints bool) {
|
|
|
|
|
// predicates checks if a DaemonSet's pod can run on a node.
|
|
|
|
|
func predicates(pod *v1.Pod, node *v1.Node, taints []v1.Taint) (fitsNodeName, fitsNodeAffinity, fitsTaints bool) {
|
|
|
|
|
fitsNodeName = len(pod.Spec.NodeName) == 0 || pod.Spec.NodeName == node.Name
|
|
|
|
|
// Ignore parsing errors for backwards compatibility.
|
|
|
|
|
fitsNodeAffinity, _ = nodeaffinity.GetRequiredNodeAffinity(pod).Match(node)
|
|
|
|
|