Skip to content

Drop redundant per-service targetRevision on ec deploy - #269

Merged
gilesknap merged 1 commit into
mainfrom
ec-group-aware-deploy
Sep 30, 2026
Merged

gilesknap merged 1 commit into
mainfrom
ec-group-aware-deploy

Conversation

@gilesknap

@gilesknap gilesknap commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Closes #268

ec deploy <service> <revision> no longer writes a per-service targetRevision when that revision equals the line the service already follows. It removes the service's own pin instead, so the service keeps following its line when the line moves.

The line is resolved exactly as the argocd-apps chart does (epics-containers/ec-helm-charts#136):

  1. versions[<group>] if the service has a group. Any group name works, including ad-hoc lines as well as daq/techui.
  2. otherwise source.targetRevision.

A service whose group has no versions entry is reported as an error; the chart would fail to render it anyway. Deployment repos without versions/group keep their behaviour.

Changes

  • git.py: new resolve_target_revision(). set_values() takes deploy_target_revision=(service, revision) and resolves it against the same clone it commits from, then writes or removes the key.
  • cmds/argo_commands.py: deploy() goes through that path. push_values() still always clears any stale live targetRevision parameter override.
  • utils.py: YamlFile.remove_key raises YamlFileError consistently, rather than a bare KeyError. A service entry left empty serialises as {}.
  • ec ps / ec monitor: unchanged, since they read the effective revision live from Argo CD.

Testing

  • 13 new tests: global line equal, group line equal, group differs, ad-hoc group name, unknown group, no versions key, and a repo without the new keys. The full suite passes (103), and ruff is clean.
  • Real run: a deployment repo generated from Team version lines and per-service group for apps values deployment-template-argocd#48, pushed to a local bare remote. set_values with real clone, commit and push removed redundant pins for both a grouped and an ungrouped service.

Part of the rollout plan in epics-containers/epics-containers.github.io#269. ec is intended to be released before the deployment-template-argocd change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UrUi8y7pYzejT8HqdzMVaj

Summary by CodeRabbit

  • New Features

    • Deployments now use the shared revision when the selected version matches it, removing any redundant service-specific version pin.
    • When a selected version differs from the shared revision, deployments retain that version as a service-specific pin.
  • Bug Fixes

    • Removing a missing configuration key now reports a consistent configuration error.
    • Configuration mappings remain intact when their last key is removed.

When the requested revision equals the line a service already follows,
remove the service's own targetRevision instead of writing a pin. The
line is versions[<group>] when the service has a group (any name), else
source.targetRevision - the same resolution as the argocd-apps chart.
A group with no versions entry is an error. Repos without versions or
group keep their behaviour.

YamlFile.remove_key now raises YamlFileError consistently.

Closes #268

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UrUi8y7pYzejT8HqdzMVaj
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 6a39b84c-3791-4e91-8ec8-26957d0eb1a1

📥 Commits

Reviewing files that changed from the base of the PR and between 33d7fa3 and d2df1ff.

📒 Files selected for processing (7)
  • src/edge_containers_cli/cmds/argo_commands.py
  • src/edge_containers_cli/git.py
  • src/edge_containers_cli/utils.py
  • tests/data/argocd.yaml
  • tests/test_argocd.py
  • tests/test_git.py
  • tests/test_unit.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Deployment now compares a requested service revision with its shared group or global revision. It removes a redundant service-level pin or writes a differing pin, then clears the service’s Argo CD targetRevision override.

Changes

Deployment revision handling

Layer / File(s) Summary
Resolve and persist service revisions
src/edge_containers_cli/git.py, src/edge_containers_cli/utils.py, tests/test_git.py, tests/test_unit.py
set_values resolves revisions from the service group or global source. It removes a pin when revisions match and sets one when they differ. Tests cover revision resolution, errors, commits, and YAML key deletion.
Pass revision through deployment
src/edge_containers_cli/cmds/argo_commands.py, tests/data/argocd.yaml, tests/test_argocd.py
deploy passes the requested revision separately to the values update flow. The flow unsets the service’s Argo CD targetRevision override. Tests and fixtures cover matching and differing revisions.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: ocopping

Merge Risk: ⚪ Minimal · up to d2df1

The change reconciles service pins with shared revisions while preserving enablement and override cleanup. No actionable merge-blocking issue remains; merge after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to d2df1

Successful deployments preserve unrelated service metadata and clear service-level revision overrides. However, removing a pin based only on committed values can make an explicit deployment or rollback follow a different live shared revision. Chart compatibility and production permissions remain unconfirmed; no new privilege escalation was established.

Retained concerns

  • Medium · reliability · inferred: Pin removal compares the request with committed YAML, not the effective live shared line. If Argo CD overrides source.targetRevision, versions for the service group, or the service group itself, those overrides survive deploy cleanup. A request matching the committed line can consequently inherit a different live revision, weakening explicit deployment and rollback control. Previously, the requested service pin took precedence. Production occurrence and external chart behavior are not established.
Security review details

Security Blast Radius

  • inferred — The changed operation targets one service entry within the selected application's deployment repository. Shared-line inheritance affects that service's subsequent revision selection. Repository, cluster, tenant and credential exposure remains bounded by existing operator permissions, whose production scope was unavailable.

Security Findings and Attack Paths

  • inferred — A conflicting live shared revision, whether stale or deliberately configured by an actor with Argo parameter-write authority, can survive deploy and become effective after pin removal. This can undermine requested-version or rollback assurance. It does not establish new parameter-write privileges or a production exploit.

Trust Boundaries and Controls

  • observed — Repository details come from the selected Argo application, and operator-selected revisions enter existing Git command execution. Commands execute through a subprocess shell. Base/head inspection found the same revision-validation and service-override command paths before this PR; the new group lookup does not introduce a new shell sink.

Resilience and Maintainability Implications

  • observed — Git persistence and live cleanup are not atomic. A persistence error skips cleanup; interruption after a successful push can leave live overrides outstanding. This ordering predates the PR and is not retained as a newly introduced concern. Repetition retries reconciliation, but external locking and recovery guarantees were not established.

Hardening Proposals

  • proposed — Before removing a pin, establish that the effective shared revision—including live shared-line and group overrides—matches the request. If equivalence or chart compatibility cannot be established, retain the explicit pin or reject the transition rather than silently transferring revision authority.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 6 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removing redundant per-service targetRevision values during ec deploy.
Linked Issues check ✅ Passed Issue #268 requires line resolution from versions[service.group], or source.targetRevision without a group; removal of a matching per-service pin; retention of a differing pin; unchanged group; …
Out of Scope Changes check ✅ Passed The reported changes support issue #268. YamlFile.remove_key enables safe removal of targetRevision, and its tests cover missing paths and empty mappings. Argo command changes, fixtures, and regre…
Full details: Docstring Coverage

Explanation

Docstring coverage is 19.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 6 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ec deploy: drop the per-service targetRevision when it matches the service's group or global revision

1 participant