Skip to content

Use sandbox pod annotation for GetSandboxPodIP#413

Open
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:fix/sandbox-pod-lookup
Open

Use sandbox pod annotation for GetSandboxPodIP#413
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:fix/sandbox-pod-lookup

Conversation

@safiya2610

@safiya2610 safiya2610 commented Jun 29, 2026

Copy link
Copy Markdown

Summary

This change makes GetSandboxPodIP prefer an explicit pod name. When no pod name is provided, it falls back to reading the SandboxPodNameAnnotation from the Sandbox resource instead of discovering the pod through labels or OwnerReferences.

Changes

  • Prefer explicit pod name when available
  • Read SandboxPodNameAnnotation from the Sandbox resource when pod name is not provided
  • Remove label/OwnerReference-based pod lookup
  • Update unit tests to use explicit pod names
  • Update tests to expect NotFound when no dynamic client/annotation is available

Fixes #277

Copilot AI review requested due to automatic review settings June 29, 2026 15:36
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

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

Copy link
Copy Markdown
Contributor

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 GetSandboxPodIP method in k8s_client.go to retrieve the backing pod name from the Sandbox resource's annotations instead of using the previous label and ownerReference fallback. It also updates the corresponding unit tests to pass explicit pod names and removes unused imports. I have no feedback to provide.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Workload Manager’s GetSandboxPodIP lookup flow to stop discovering pods via labels/OwnerReferences and instead rely on an explicit pod name (caller-provided) or the authoritative SandboxPodNameAnnotation stored on the Sandbox resource (via dynamic client).

Changes:

  • Prefer direct pod lookup by explicit podName using the pod lister cache.
  • When podName is not provided, read controllers.SandboxPodNameAnnotation from the Sandbox resource and use it to resolve the pod.
  • Update unit tests to pass explicit pod names and adjust expectations when no dynamic client is available.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/workloadmanager/k8s_client.go Reworks GetSandboxPodIP to use explicit pod name and Sandbox annotation fallback; removes label/OwnerReference discovery.
pkg/workloadmanager/k8s_client_test.go Updates tests to pass explicit pod names and to expect “not found” when annotation lookup can’t run.
go.sum Removes unused golang.org/x/oauth2 v0.36.0 sums (module tidying).

Comment thread pkg/workloadmanager/k8s_client.go
Comment thread pkg/workloadmanager/k8s_client.go
Comment thread pkg/workloadmanager/k8s_client_test.go Outdated
Comment thread pkg/workloadmanager/k8s_client.go
@codecov-commenter

codecov-commenter commented Jun 29, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.66%. Comparing base (524e55e) to head (65d38f5).
⚠️ Report is 146 commits behind head on main.

Files with missing lines Patch % Lines
pkg/workloadmanager/k8s_client.go 62.50% 5 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #413       +/-   ##
===========================================
+ Coverage   47.57%   58.66%   +11.09%     
===========================================
  Files          30       37        +7     
  Lines        2819     3493      +674     
===========================================
+ Hits         1341     2049      +708     
+ Misses       1338     1235      -103     
- Partials      140      209       +69     
Flag Coverage Δ
unittests 58.66% <62.50%> (+11.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.

Comment on lines 318 to 324
if podName != "" {
pod, err := c.podLister.Pods(namespace).Get(podName)
if err == nil && pod != nil {
return validateAndGetPodIP(pod)
}
klog.Infof("failed to get sandbox pod %s/%s: %v, try get pod by sandbox-name label", namespace, podName, err)
klog.Infof("failed to get sandbox pod %s/%s: %v", namespace, podName, err)
}
Comment on lines +337 to 344
if ann := sb.GetAnnotations()[controllers.SandboxPodNameAnnotation]; ann != "" {
podName = ann
pod, err := c.podLister.Pods(namespace).Get(podName)
if err == nil && pod != nil {
return validateAndGetPodIP(pod)
}
klog.Infof("failed to get sandbox pod %s/%s from annotation: %v", namespace, podName, err)
}
}

phase, found, err := unstructured.NestedString(status, "phase")
// OPTIMIZATION: Flatten nested loop parameters using unstructured fields path syntax directly
Comment on lines +228 to +231
TypeMeta: metav1.TypeMeta{
APIVersion: "agents.x-k8s.io/v1alpha1",
Kind: "Sandbox",
},
Comment on lines +329 to +331
if c.dynamicClient == nil {
return "", fmt.Errorf("no pod found for sandbox %s: dynamic client not configured", sandboxName)
}
@safiya2610

Copy link
Copy Markdown
Author

@hzxuzhonghu Hello, Please review this PR, this PR Simplify sandbox pod match #277 .

Signed-off-by: Safiya <147792763+safiya2610@users.noreply.github.com>
@safiya2610 safiya2610 force-pushed the fix/sandbox-pod-lookup branch from 7613f05 to 65d38f5 Compare June 29, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify sandbox pod match

4 participants