fix(deploy): abort foreign legacy pod conflicts#353
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Reviewer's GuideThis PR hardens Quadlet deployment by introducing environment-specific namespaces for generated systemd units, refining stack ownership detection to distinguish safe legacy reuse from foreign conflicts, and updating documentation/tests to cover the new isolation and local llama.cpp fallback behavior. Sequence diagram for Quadlet stack ownership and conflict-aware deploymentsequenceDiagram
actor Dev
participant start_stack_sh
participant podman
participant systemd_user
Dev->>start_stack_sh: run start_stack.sh
start_stack_sh->>podman: podman pod exists POD_NAME
podman-->>start_stack_sh: infra container id
start_stack_sh->>podman: podman inspect PODMAN_SYSTEMD_UNIT
podman-->>start_stack_sh: infra_unit
alt infra_unit equals LLM_ROUTING_POD_UNIT
start_stack_sh-->>start_stack_sh: stack_ownership returns quadlet:LLM_ROUTING_POD_UNIT
else infra_unit equals LEGACY_LLM_ROUTING_POD_UNIT
start_stack_sh->>systemd_user: legacy_unit_owns_pod LEGACY_LLM_ROUTING_POD_UNIT
alt legacy unit owns POD_NAME
systemd_user-->>start_stack_sh: true
start_stack_sh-->>start_stack_sh: stack_ownership returns quadlet:LEGACY_LLM_ROUTING_POD_UNIT
else legacy unit does not own POD_NAME
systemd_user-->>start_stack_sh: false
start_stack_sh-->>start_stack_sh: stack_ownership returns conflict:LEGACY_LLM_ROUTING_POD_UNIT
end
else no matching infra_unit
start_stack_sh-->>start_stack_sh: stack_ownership returns legacy or absent
end
start_stack_sh-->>start_stack_sh: STACK_OWNERSHIP=$(stack_ownership)
alt STACK_OWNERSHIP starts with conflict:
start_stack_sh-->>Dev: print error and exit 1
else STACK_OWNERSHIP starts with quadlet:
start_stack_sh->>systemd_user: require_user_systemd
systemd_user-->>start_stack_sh: ok
start_stack_sh-->>start_stack_sh: owner_unit=${STACK_OWNERSHIP#quadlet:}
start_stack_sh->>systemd_user: systemctl --user stop owner_unit
start_stack_sh->>systemd_user: systemctl --user reset-failed owner_unit
start_stack_sh->>podman: podman pod rm -f POD_NAME
start_stack_sh->>systemd_user: systemctl --user restart owner_unit
systemd_user-->>Dev: Quadlet stack restarted
else STACK_OWNERSHIP is legacy or absent
start_stack_sh-->>Dev: deploy_fresh_pod
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe deployment script now namespaces Quadlet units per environment, detects exact or conflicting ownership, and restarts or tears down the corresponding systemd unit. Dev configuration, documentation, fallback diagrams, and deployment-contract tests were updated for the new naming and isolation behavior. ChangesEnvironment-isolated Quadlet deployment
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant start_stack as start-stack.sh
participant systemd as systemctl --user
participant Podman
Operator->>start_stack: Start or replace stack
start_stack->>systemd: Inspect namespaced and legacy units
systemd-->>start_stack: Return owner or conflict
alt Existing Quadlet owner
start_stack->>systemd: Restart exact owner unit
systemd->>Podman: Manage namespaced pod
else No conflict
start_stack->>Podman: Render and deploy namespaced Quadlets
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Hey - I've found 1 issue, and left some high level feedback:
- In the embedded Python
namespace_identifierhelper, theelif field == "Pod"branch is unreachable becausePodis already handled in the firstifclause; consider simplifying this logic and avoiding the duplicatedllm-routing.podreplacement to make the namespacing rules clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the embedded Python `namespace_identifier` helper, the `elif field == "Pod"` branch is unreachable because `Pod` is already handled in the first `if` clause; consider simplifying this logic and avoiding the duplicated `llm-routing.pod` replacement to make the namespacing rules clearer.
## Individual Comments
### Comment 1
<location path="start-stack.sh" line_range="808-814" />
<code_context>
+ # paths, or other configuration values containing "llm-routing".
+ # Namespace only Quadlet identifier lines and values. This preserves
+ # arbitrary image names, URLs, and credentials containing llm-routing.
+ def namespace_identifier(match):
+ field, value = match.group(1), match.group(2)
+ if field in {"Pod", "After", "Wants", "BindsTo", "Requires", "PartOf"}:
+ value = identifier_prefix.sub(namespace + "-", value)
+ value = value.replace("llm-routing.pod", namespace + ".pod")
+ value = value.replace("llm-routing-pod.service", namespace + "-pod.service")
+ elif field == "Pod":
+ value = value.replace("llm-routing.pod", namespace + ".pod")
+ return f"{field}={value}"
</code_context>
<issue_to_address>
**issue:** The `namespace_identifier` function has an unreachable `elif field == "Pod"` branch.
Because the first `if` already matches `"Pod"` (and other fields), the subsequent `elif field == "Pod"` is dead code. This is confusing and could mask issues if the condition set changes later. Either separate the handling for `"Pod"` (remove it from the first set and keep a distinct branch) or remove the redundant `elif` if the extra behavior is no longer needed.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@start-stack.sh`:
- Around line 558-562: Update legacy_unit_owns_pod to inspect the generated
ExecStartPre command and match the pod name passed to podman pod create,
supporting both --name= and space-separated --name forms instead of the PodName
source line. Extend the regression test to cover ownership detection from
generated service output.
In `@tests/test_quadlet_templates.py`:
- Around line 130-132: Split the semicolon-separated src.mkdir() and out.mkdir()
statements in the TemporaryDirectory setup into separate statements, preserving
the existing directory creation behavior.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e8131469-8db6-48fb-9bba-d6e9e3e918fb
📒 Files selected for processing (5)
.env.devREADME.mdscripts/README.mdstart-stack.shtests/test_quadlet_templates.py
Supersedes #352.
Final review fixes:
local-qwen-3.6) before the Ollama and OpenRouter fallbacks.Validation:
bash -n start-stack.shpassed.git diff --checkpassed.conflict:llm-routing-pod.serviceand aborts safely.http://127.0.0.1:8083remains reachable with the approved local models.Summary by Sourcery
Isolate Quadlet deployment between dev and prod environments and harden stack ownership detection so foreign legacy units cannot be torn down or reused, while updating routing documentation for the local llama.cpp safety net.
New Features:
Bug Fixes:
Enhancements:
Tests:
Summary by CodeRabbit
New Features
Documentation
Bug Fixes