Skip to content

[release-1.14] Fix isDependsOnPodsReady to treat Succeeded pods as ready - #5547

Merged
volcano-sh-bot merged 1 commit into
volcano-sh:release-1.14from
volcano-sh-bot:cherry-pick-5439-to-release-1.14
Jun 30, 2026
Merged

[release-1.14] Fix isDependsOnPodsReady to treat Succeeded pods as ready#5547
volcano-sh-bot merged 1 commit into
volcano-sh:release-1.14from
volcano-sh-bot:cherry-pick-5439-to-release-1.14

Conversation

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

This is an automated cherry-pick of #5439

Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the isDependsOnPodsReady method in the job controller to correctly count succeeded pods as running pods, and adds comprehensive unit tests to verify this behavior. The review feedback suggests improving the test setup by using the returned objects from the fake client's Create calls when adding them to the cache and informer indexers, as well as replacing context.TODO() with context.Background().

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1704 to +1712
_, err := fakeController.vcClient.BatchV1alpha1().Jobs(namespace).Create(context.TODO(), tc.Job, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create job: %v", err)
}
err = fakeController.cache.Add(tc.Job)
if err != nil {
t.Fatalf("Failed to add job to cache: %v", err)
}
fakeController.jobInformer.Informer().GetIndexer().Add(tc.Job)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is recommended to use the returned createdJob object from the fake client's Create method when adding it to the cache and informer indexer. This ensures that any system-populated fields (such as UID, ResourceVersion, or default values) are preserved in the local caches, preventing potential discrepancies in controller tests. Additionally, context.Background() is preferred over context.TODO() in test contexts.

Suggested change
_, err := fakeController.vcClient.BatchV1alpha1().Jobs(namespace).Create(context.TODO(), tc.Job, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create job: %v", err)
}
err = fakeController.cache.Add(tc.Job)
if err != nil {
t.Fatalf("Failed to add job to cache: %v", err)
}
fakeController.jobInformer.Informer().GetIndexer().Add(tc.Job)
createdJob, err := fakeController.vcClient.BatchV1alpha1().Jobs(namespace).Create(context.Background(), tc.Job, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create job: %v", err)
}
err = fakeController.cache.Add(createdJob)
if err != nil {
t.Fatalf("Failed to add job to cache: %v", err)
}
fakeController.jobInformer.Informer().GetIndexer().Add(createdJob)

Comment on lines +1714 to +1720
for _, pod := range tc.Pods {
_, err := fakeController.kubeClient.CoreV1().Pods(namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create pod: %v", err)
}
fakeController.podInformer.Informer().GetIndexer().Add(pod)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly to the Job creation, it is recommended to use the returned createdPod object from the fake client's Create method when adding it to the informer indexer to ensure system-populated fields are preserved. Also, context.Background() should be used instead of context.TODO().

Suggested change
for _, pod := range tc.Pods {
_, err := fakeController.kubeClient.CoreV1().Pods(namespace).Create(context.TODO(), pod, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create pod: %v", err)
}
fakeController.podInformer.Informer().GetIndexer().Add(pod)
}
for _, pod := range tc.Pods {
createdPod, err := fakeController.kubeClient.CoreV1().Pods(namespace).Create(context.Background(), pod, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create pod: %v", err)
}
fakeController.podInformer.Informer().GetIndexer().Add(createdPod)
}

@JesseStutler

Copy link
Copy Markdown
Member

/approve
/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2026
@volcano-sh-bot

Copy link
Copy Markdown
Contributor Author

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JesseStutler

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2026
@volcano-sh-bot
volcano-sh-bot merged commit efd96fa into volcano-sh:release-1.14 Jun 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants