mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
Do not preallocate node for Job e2e tests to fix flakes
This commit is contained in:
parent
8453eb0c24
commit
69ca55f136
@ -80,11 +80,15 @@ func NewTestJobOnNode(behavior, name string, rPol v1.RestartPolicy, parallelism,
|
||||
SecurityContext: &v1.SecurityContext{},
|
||||
},
|
||||
},
|
||||
NodeName: nodeName,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if len(nodeName) > 0 {
|
||||
job.Spec.Template.Spec.NodeSelector = map[string]string{
|
||||
"kubernetes.io/hostname": nodeName,
|
||||
}
|
||||
}
|
||||
switch behavior {
|
||||
case "notTerminate":
|
||||
job.Spec.Template.Spec.Containers[0].Command = []string{"sleep", "1000000"}
|
||||
@ -119,7 +123,7 @@ func NewTestJobOnNode(behavior, name string, rPol v1.RestartPolicy, parallelism,
|
||||
|
||||
// setup host path directory to pass information between pod restarts
|
||||
func setupHostPathDirectory(job *batchv1.Job) {
|
||||
if len(job.Spec.Template.Spec.NodeName) > 0 {
|
||||
if _, nodeNameSpecified := job.Spec.Template.Spec.NodeSelector["kubernetes.io/hostname"]; nodeNameSpecified {
|
||||
randomDir := "/tmp/job-e2e/" + rand.String(10)
|
||||
hostPathType := v1.HostPathDirectoryOrCreate
|
||||
job.Spec.Template.Spec.Volumes[0].VolumeSource = v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: randomDir, Type: &hostPathType}}
|
||||
|
Loading…
Reference in New Issue
Block a user