mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #121017 from kannon92/fix-apps-issue
Remove consistent check in test for job suspend
This commit is contained in:
		@@ -280,31 +280,18 @@ var _ = SIGDescribe("Job", func() {
 | 
				
			|||||||
		job, err := e2ejob.CreateJob(ctx, f.ClientSet, f.Namespace.Name, job)
 | 
							job, err := e2ejob.CreateJob(ctx, f.ClientSet, f.Namespace.Name, job)
 | 
				
			||||||
		framework.ExpectNoError(err, "failed to create job in namespace: %s", f.Namespace.Name)
 | 
							framework.ExpectNoError(err, "failed to create job in namespace: %s", f.Namespace.Name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ginkgo.By("Ensuring pods aren't created for job")
 | 
					 | 
				
			||||||
		err = framework.Gomega().Consistently(ctx, framework.HandleRetry(func(ctx context.Context) ([]v1.Pod, error) {
 | 
					 | 
				
			||||||
			pods, err := e2ejob.GetJobPods(ctx, f.ClientSet, f.Namespace.Name, job.Name)
 | 
					 | 
				
			||||||
			if err != nil {
 | 
					 | 
				
			||||||
				return nil, fmt.Errorf("failed to list pod for a given job %s in namespace %s: %w", job.Name, f.Namespace.Name, err)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return pods.Items, nil
 | 
					 | 
				
			||||||
		})).WithPolling(framework.Poll).WithTimeout(wait.ForeverTestTimeout).Should(gomega.BeEmpty())
 | 
					 | 
				
			||||||
		framework.ExpectNoError(err, "failed to confirm that pods aren't created for job %s in namespace %s", job.Name, f.Namespace.Name)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ginkgo.By("Checking Job status to observe Suspended state")
 | 
							ginkgo.By("Checking Job status to observe Suspended state")
 | 
				
			||||||
		job, err = e2ejob.GetJob(ctx, f.ClientSet, f.Namespace.Name, job.Name)
 | 
							err = e2ejob.WaitForJobSuspend(ctx, f.ClientSet, f.Namespace.Name, job.Name)
 | 
				
			||||||
		framework.ExpectNoError(err, "failed to retrieve latest job object")
 | 
							framework.ExpectNoError(err, "failed to observe suspend state: %s", f.Namespace.Name)
 | 
				
			||||||
		exists := false
 | 
					
 | 
				
			||||||
		for _, c := range job.Status.Conditions {
 | 
							ginkgo.By("Ensuring pods aren't created for job")
 | 
				
			||||||
			if c.Type == batchv1.JobSuspended {
 | 
							pods, err := e2ejob.GetJobPods(ctx, f.ClientSet, f.Namespace.Name, job.Name)
 | 
				
			||||||
				exists = true
 | 
							framework.ExpectNoError(err, "failed to list pod for a given job %s in namespace %s", job.Name, f.Namespace.Name)
 | 
				
			||||||
				break
 | 
							gomega.Expect(pods.Items).To(gomega.BeEmpty())
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if !exists {
 | 
					 | 
				
			||||||
			framework.Failf("Job was expected to be completed or failed")
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ginkgo.By("Updating the job with suspend=false")
 | 
							ginkgo.By("Updating the job with suspend=false")
 | 
				
			||||||
 | 
							job, err = f.ClientSet.BatchV1().Jobs(f.Namespace.Name).Get(ctx, job.Name, metav1.GetOptions{})
 | 
				
			||||||
 | 
							framework.ExpectNoError(err, "failed to get job in namespace: %s", f.Namespace.Name)
 | 
				
			||||||
		job.Spec.Suspend = pointer.BoolPtr(false)
 | 
							job.Spec.Suspend = pointer.BoolPtr(false)
 | 
				
			||||||
		job, err = e2ejob.UpdateJob(ctx, f.ClientSet, f.Namespace.Name, job)
 | 
							job, err = e2ejob.UpdateJob(ctx, f.ClientSet, f.Namespace.Name, job)
 | 
				
			||||||
		framework.ExpectNoError(err, "failed to update job in namespace: %s", f.Namespace.Name)
 | 
							framework.ExpectNoError(err, "failed to update job in namespace: %s", f.Namespace.Name)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,6 +88,18 @@ func WaitForJobReady(ctx context.Context, c clientset.Interface, ns, jobName str
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// WaitForJobSuspend uses c to wait for suspend condition for the Job jobName in namespace ns.
 | 
				
			||||||
 | 
					func WaitForJobSuspend(ctx context.Context, c clientset.Interface, ns, jobName string) error {
 | 
				
			||||||
 | 
						return WaitForJobState(ctx, c, ns, jobName, JobTimeout, func(job *batchv1.Job) string {
 | 
				
			||||||
 | 
							for _, c := range job.Status.Conditions {
 | 
				
			||||||
 | 
								if c.Type == batchv1.JobSuspended && c.Status == v1.ConditionTrue {
 | 
				
			||||||
 | 
									return ""
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return "job should be suspended"
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WaitForJobFailed uses c to wait for the Job jobName in namespace ns to fail
 | 
					// WaitForJobFailed uses c to wait for the Job jobName in namespace ns to fail
 | 
				
			||||||
func WaitForJobFailed(c clientset.Interface, ns, jobName string) error {
 | 
					func WaitForJobFailed(c clientset.Interface, ns, jobName string) error {
 | 
				
			||||||
	return wait.PollImmediate(framework.Poll, JobTimeout, func() (bool, error) {
 | 
						return wait.PollImmediate(framework.Poll, JobTimeout, func() (bool, error) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user