Skip to content

Commit dc8208d

Browse files
authored
Merge pull request kubernetes#87871 from msau42/fix-hostexec
Use NodeSelector instead of NodeName in hostexec Pod
2 parents 6eba154 + 1ee35e7 commit dc8208d

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
@@ -73,9 +73,14 @@ func (h *hostExecutor) launchNodeExecPod(node string) *v1.Pod {
7373
f := h.Framework
7474
cs := f.ClientSet
7575
ns := f.Namespace
76+
7677
hostExecPod := e2epod.NewExecPodSpec(ns.Name, "", true)
7778
hostExecPod.GenerateName = fmt.Sprintf("hostexec-%s-", node)
78-
hostExecPod.Spec.NodeName = node
79+
// Use NodeAffinity instead of NodeName so that pods will not
80+
// be immediately Failed by kubelet if it's out of space. Instead
81+
// Pods will be pending in the scheduler until there is space freed
82+
// up.
83+
e2epod.SetNodeAffinity(hostExecPod, node)
7984
hostExecPod.Spec.Volumes = []v1.Volume{
8085
{
8186
// Required to enter into host mount namespace via nsenter.

0 commit comments

Comments
 (0)