Skip to content

Commit 1ee35e7

Browse files
committed
Use NodeSelector instead of NodeName in hostexec Pod so that the Pod runs through the scheduler
Change-Id: Ia2f7ad39af318bbe707b43dfea706293ecdf5203
1 parent 845b232 commit 1ee35e7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

test/e2e/framework/pod/node_selection.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ func SetAffinity(nodeSelection *NodeSelection, nodeName string) {
7979
func SetAntiAffinity(nodeSelection *NodeSelection, nodeName string) {
8080
setNodeAffinityRequirement(nodeSelection, v1.NodeSelectorOpNotIn, nodeName)
8181
}
82+
83+
// SetNodeAffinity modifies the given pod object with
84+
// NodeAffinity to the given node name.
85+
func SetNodeAffinity(pod *v1.Pod, nodeName string) {
86+
nodeSelection := &NodeSelection{}
87+
SetAffinity(nodeSelection, nodeName)
88+
pod.Spec.Affinity = nodeSelection.Affinity
89+
}

test/e2e/storage/utils/host_exec.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ func (h *hostExecutor) launchNodeExecPod(node string) *v1.Pod {
7171
f := h.Framework
7272
cs := f.ClientSet
7373
ns := f.Namespace
74+
7475
hostExecPod := e2epod.NewExecPodSpec(ns.Name, "", true)
7576
hostExecPod.GenerateName = fmt.Sprintf("hostexec-%s-", node)
76-
hostExecPod.Spec.NodeName = node
77+
// Use NodeAffinity instead of NodeName so that pods will not
78+
// be immediately Failed by kubelet if it's out of space. Instead
79+
// Pods will be pending in the scheduler until there is space freed
80+
// up.
81+
e2epod.SetNodeAffinity(hostExecPod, node)
7782
hostExecPod.Spec.Volumes = []v1.Volume{
7883
{
7984
// Required to enter into host mount namespace via nsenter.

0 commit comments

Comments
 (0)