From abee0ce8a358b8a11dec874d080bbba5b6dac216 Mon Sep 17 00:00:00 2001 From: Klaus Ma Date: Mon, 14 Aug 2017 15:17:56 +0800 Subject: [PATCH] NodeConditionPredicates should return NodeOutOfDisk error. --- pkg/controller/daemon/daemon_controller.go | 2 +- .../daemon/daemon_controller_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/controller/daemon/daemon_controller.go b/pkg/controller/daemon/daemon_controller.go index 93673f07766..0c8a4ff3e65 100644 --- a/pkg/controller/daemon/daemon_controller.go +++ b/pkg/controller/daemon/daemon_controller.go @@ -1351,7 +1351,7 @@ func NodeConditionPredicates(nodeInfo *schedulercache.NodeInfo) (bool, []algorit // TODO: There are other node status that the DaemonSet should ideally respect too, // e.g. MemoryPressure, and DiskPressure if c.Type == v1.NodeOutOfDisk && c.Status == v1.ConditionTrue { - reasons = append(reasons, predicates.ErrNodeSelectorNotMatch) + reasons = append(reasons, predicates.ErrNodeOutOfDisk) break } } diff --git a/pkg/controller/daemon/daemon_controller_test.go b/pkg/controller/daemon/daemon_controller_test.go index f8e49d48854..097f4cc1a23 100644 --- a/pkg/controller/daemon/daemon_controller_test.go +++ b/pkg/controller/daemon/daemon_controller_test.go @@ -1394,6 +1394,7 @@ func setDaemonSetCritical(ds *extensions.DaemonSet) { func TestNodeShouldRunDaemonPod(t *testing.T) { cases := []struct { podsOnNode []*v1.Pod + nodeCondition []v1.NodeCondition ds *extensions.DaemonSet wantToRun, shouldSchedule, shouldContinueRunning bool err error @@ -1414,6 +1415,23 @@ func TestNodeShouldRunDaemonPod(t *testing.T) { shouldSchedule: true, shouldContinueRunning: true, }, + { + ds: &extensions.DaemonSet{ + Spec: extensions.DaemonSetSpec{ + Selector: &metav1.LabelSelector{MatchLabels: simpleDaemonSetLabel}, + Template: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: simpleDaemonSetLabel, + }, + Spec: resourcePodSpec("", "50M", "0.5"), + }, + }, + }, + nodeCondition: []v1.NodeCondition{{Type: v1.NodeOutOfDisk, Status: v1.ConditionTrue}}, + wantToRun: true, + shouldSchedule: false, + shouldContinueRunning: true, + }, { ds: &extensions.DaemonSet{ Spec: extensions.DaemonSetSpec{ @@ -1484,6 +1502,7 @@ func TestNodeShouldRunDaemonPod(t *testing.T) { for i, c := range cases { for _, strategy := range updateStrategies() { node := newNode("test-node", nil) + node.Status.Conditions = append(node.Status.Conditions, c.nodeCondition...) node.Status.Allocatable = allocatableResources("100M", "1") manager, _, _ := newTestController() manager.nodeStore.Add(node)