fix: handle NotFound and add ownerReferences in BarePodManager#322
fix: handle NotFound and add ownerReferences in BarePodManager#322tremes wants to merge 1 commit into
Conversation
WaitReady now treats NotFound as a terminal error instead of polling until timeout. It also checks DeletionTimestamp after a successful Get to fail fast on terminating pods. Sandbox pods created by Claim now carry ownerReferences back to the AgenticRun via the new SandboxOwnerSetter optional interface, enabling garbage collection on AgenticRun deletion. Closes: openshift#301 Signed-off-by: Tomáš Remeš <tremes@redhat.com> Assisted-by: Claude Code:claude-opus-4-6
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesBare-pod sandbox lifecycle
Sequence Diagram(s)sequenceDiagram
participant SandboxAgentCaller
participant BarePodManager
participant KubernetesAPI
SandboxAgentCaller->>BarePodManager: SetOwner(run)
SandboxAgentCaller->>BarePodManager: Claim()
BarePodManager->>KubernetesAPI: Create Pod with ownerReference
SandboxAgentCaller->>BarePodManager: WaitReady()
BarePodManager->>KubernetesAPI: Get Pod
KubernetesAPI-->>BarePodManager: Ready or terminal lifecycle state
BarePodManager-->>SandboxAgentCaller: Ready or error
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@controller/agenticrun/bare_pod_manager.go`:
- Around line 63-67: Remove mutable owner state from BarePodManager by
eliminating SetOwner and the m.run dependency; change Claim to accept the owning
AgenticRun explicitly and use that argument when constructing the pod
ownerReference. Update all Claim callers, including SandboxAgentCaller, to pass
the reconcile-specific run so concurrent reconciles cannot attach pods to the
wrong owner.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 439a5b81-0f6a-4beb-8a84-4643f83f599a
📒 Files selected for processing (6)
.ai/spec/how/reconciler.md.ai/spec/what/sandbox-execution.mdcontroller/agenticrun/bare_pod_manager.gocontroller/agenticrun/bare_pod_manager_test.gocontroller/agenticrun/sandbox.gocontroller/agenticrun/sandbox_agent.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
openshift/lightspeed-agentic-sandbox(manual)
| // SetOwner stores the AgenticRun so that pods created by Claim carry an | ||
| // ownerReference back to the run, enabling garbage collection. | ||
| func (m *BarePodManager) SetOwner(run *agenticv1alpha1.AgenticRun) { | ||
| m.run = run | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check how SandboxAgentCaller and its SandboxProvider are constructed and whether
# the BarePodManager instance is shared across reconciles.
# 1. Find where SandboxAgentCaller is constructed
rg -nC5 'NewSandboxAgentCaller' --type=go controller/
# 2. Find where BarePodManager is constructed
rg -nC5 'NewBarePodManager' --type=go controller/
# 3. Check if the reconciler holds a shared AgentCaller (and thus shared Sandbox)
rg -nC5 'Agent\s+AgentCaller' --type=go controller/Repository: openshift/lightspeed-agentic-operator
Length of output: 16961
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Project overview and reading order
sed -n '1,220p' .ai/spec/README.md
# Relevant implementation files
echo '--- controller/setup.go ---'
cat -n controller/setup.go | sed -n '1,220p'
echo '--- controller/agenticrun/reconciler.go ---'
cat -n controller/agenticrun/reconciler.go | sed -n '1,260p'
echo '--- controller/agenticrun/sandbox_agent.go ---'
cat -n controller/agenticrun/sandbox_agent.go | sed -n '1,260p'
echo '--- controller/agenticrun/bare_pod_manager.go ---'
cat -n controller/agenticrun/bare_pod_manager.go | sed -n '1,260p'Repository: openshift/lightspeed-agentic-operator
Length of output: 37103
Avoid mutable owner state on BarePodManager
Setup builds one BarePodManager and shares it through a single SandboxAgentCaller instance across reconciles, while the controller can run more than one reconcile at a time. SetOwner/Claim can race and attach a pod to the wrong AgenticRun, which can trigger incorrect garbage collection. Pass the owner into Claim or make the provider stateless.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@controller/agenticrun/bare_pod_manager.go` around lines 63 - 67, Remove
mutable owner state from BarePodManager by eliminating SetOwner and the m.run
dependency; change Claim to accept the owning AgenticRun explicitly and use that
argument when constructing the pod ownerReference. Update all Claim callers,
including SandboxAgentCaller, to pass the reconcile-specific run so concurrent
reconciles cannot attach pods to the wrong owner.
|
@tremes: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
WaitReady now treats NotFound as a terminal error instead of polling until timeout. It also checks DeletionTimestamp after a successful Get to fail fast on terminating pods.
Sandbox pods created by Claim now carry ownerReferences back to the AgenticRun via the new SandboxOwnerSetter optional interface, enabling garbage collection on AgenticRun deletion.
Closes: #301
Assisted-by: Claude Code:claude-opus-4-6