Merge pull request #121487 from mimowo/fix-flaky-e2e-tests-for-job

Do not preallocate node for Job e2e tests to fix flakes
This commit is contained in:
Kubernetes Prow Robot 2023-10-26 01:08:32 +02:00 committed by GitHub
commit e0eb5edbf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"}
@ -129,7 +133,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}}