Skip to content

Make argocd manifest fetching more generic - #251

Merged
OCopping merged 6 commits into
mainfrom
generic-manifest-fetch
Jul 27, 2026
Merged

Make argocd manifest fetching more generic#251
OCopping merged 6 commits into
mainfrom
generic-manifest-fetch

Conversation

@OCopping

@OCopping OCopping commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved Argo CD application-to-manifest matching using argocd.argoproj.io/tracking-id, including stronger fallbacks when annotation or related metadata is missing.
    • More reliable service metadata in generated results, including readiness from health status, label population, and deployed timestamp updates.
    • Safer handling of partial or delayed live resource data during concurrent retrieval to avoid unexpected command failures.
  • Tests
    • Updated argocd app list test expectations to include an explicit health.status: Healthy field for the relevant entry.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bab7655f-2863-48c6-b3a5-e966d86fe71d

📥 Commits

Reviewing files that changed from the base of the PR and between d952f8c and 8b4734a.

📒 Files selected for processing (1)
  • src/edge_containers_cli/cmds/argo_commands.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/edge_containers_cli/cmds/argo_commands.py

📝 Walkthrough

Walkthrough

Updates ArgoCD application manifest extraction to skip umbrella applications, match owned top-level apps resources through tracking IDs, derive service metadata from Application and workload fields, and handle extraction errors from concurrent tasks.

Changes

ArgoCD manifest extraction

Layer / File(s) Summary
Tracking-ID-based manifest selection
src/edge_containers_cli/cmds/argo_commands.py, tests/data/argocd.yaml
Adds tracking-ID parsing, defensively processes Application resources, skips app-of-apps entries, fetches and filters live workloads, derives service metadata from health and manifest fields, handles captured ValueError exceptions, and updates the ArgoCD fixture with health.status: Healthy.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ArgoApplication
  participant _extract_app_manifests
  participant LiveManifests
  ArgoApplication->>_extract_app_manifests: provide resources, health, metadata, and source revision
  _extract_app_manifests->>LiveManifests: fetch live manifests under semaphore
  LiveManifests-->>_extract_app_manifests: return tracking-ID-owned apps workloads
  _extract_app_manifests-->>ArgoApplication: return service metadata
Loading

Suggested reviewers: gilesknap

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 accurately reflects the main change: making ArgoCD manifest fetching more generic and defensive.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch generic-manifest-fetch

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.

❤️ Share

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/edge_containers_cli/cmds/argo_commands.py (1)

312-322: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate live-manifest fetch/parse logic with _get_service_manifest.

This fetch-and-parse block (argocd app manifests ... --source live + YAML(typ="safe").load_all(...) + isinstance(manifest, dict) guard) duplicates the same pattern in _get_service_manifest (Lines 210-220). Extracting a shared helper (e.g. _get_live_manifests(namespace, name) -> Iterator[dict]) would reduce duplication and keep both call sites in sync if the command or parsing changes.

🤖 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 `@src/edge_containers_cli/cmds/argo_commands.py` around lines 312 - 322,
Extract the duplicated live-manifest command execution and YAML parsing into a
shared helper, such as _get_live_manifests(namespace, name), returning only
dictionary manifests. Replace the inline block in the shown resource-processing
flow and the equivalent logic in _get_service_manifest with this helper,
preserving semaphore usage and existing empty/non-dictionary filtering behavior.
🤖 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 `@src/edge_containers_cli/cmds/argo_commands.py`:
- Around line 299-310: Update the fallback label lookup in the
application-processing flow to read the metadata label named description instead
of device. Keep the existing "service" default for missing labels and leave the
timestamp handling unchanged.
- Around line 352-374: Update the workload readiness logic in the manifest
selection block to use DaemonSet-specific status fields when kind is
"DaemonSet", while preserving readyReplicas handling for other workload kinds.
Guard the metadata.creationTimestamp lookup and parsing so missing or invalid
timestamps do not propagate an exception that aborts service listing.

---

Nitpick comments:
In `@src/edge_containers_cli/cmds/argo_commands.py`:
- Around line 312-322: Extract the duplicated live-manifest command execution
and YAML parsing into a shared helper, such as _get_live_manifests(namespace,
name), returning only dictionary manifests. Replace the inline block in the
shown resource-processing flow and the equivalent logic in _get_service_manifest
with this helper, preserving semaphore usage and existing empty/non-dictionary
filtering 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

Run ID: b7af1aad-ac70-41b6-bc9f-958161e199c1

📥 Commits

Reviewing files that changed from the base of the PR and between d4ed8bf and c052b5d.

📒 Files selected for processing (1)
  • src/edge_containers_cli/cmds/argo_commands.py

Comment thread src/edge_containers_cli/cmds/argo_commands.py Outdated
Comment thread src/edge_containers_cli/cmds/argo_commands.py Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/edge_containers_cli/cmds/argo_commands.py (1)

291-297: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not classify mixed-resource applications as umbrellas.

The presence of any child Application causes an early return, even when the same app owns real workloads. Only skip after confirming that no owned apps-group workload exists.

🤖 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 `@src/edge_containers_cli/cmds/argo_commands.py` around lines 291 - 297, Update
the umbrella-detection condition in the resource-processing flow so an
application is skipped only when it has child Application resources and no owned
apps-group workload. Do not return based solely on any resource with kind
“Application”; inspect the existing resource metadata to confirm the absence of
a real apps workload before returning, while preserving normal processing for
mixed-resource applications.
🤖 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 `@src/edge_containers_cli/cmds/argo_commands.py`:
- Around line 371-378: Update the workload-manifest search around the
description label lookup so it only breaks after finding a valid
`metadata.labels.description`; when the first top-level workload lacks that
label, continue scanning subsequent `apps` manifests and retain the existing
fallback behavior if none provides one.

---

Outside diff comments:
In `@src/edge_containers_cli/cmds/argo_commands.py`:
- Around line 291-297: Update the umbrella-detection condition in the
resource-processing flow so an application is skipped only when it has child
Application resources and no owned apps-group workload. Do not return based
solely on any resource with kind “Application”; inspect the existing resource
metadata to confirm the absence of a real apps workload before returning, while
preserving normal processing for mixed-resource applications.
🪄 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

Run ID: afccab66-9898-4e9d-a2a3-f70f19e2f60e

📥 Commits

Reviewing files that changed from the base of the PR and between c052b5d and 5292dcd.

📒 Files selected for processing (1)
  • src/edge_containers_cli/cmds/argo_commands.py

Comment thread src/edge_containers_cli/cmds/argo_commands.py Outdated
@OCopping

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/edge_containers_cli/cmds/argo_commands.py (1)

320-323: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard dictionary lookups on API resources to prevent TaskGroup abortion.

Unguarded accesses to expected keys can raise a KeyError if the Kubernetes or ArgoCD resource is missing them (e.g., if an app uses sources instead of source). Because this runs inside a TaskGroup, a single KeyError will cancel all other concurrently running extraction tasks and abort the entire ps command.

  • src/edge_containers_cli/cmds/argo_commands.py#L320-L323: use .get() with a fallback (e.g., datetime.min) to safely read the app's creationTimestamp.
  • src/edge_containers_cli/cmds/argo_commands.py#L388-L391: use .get() or a try/except block to safely read the manifest's creationTimestamp.
  • src/edge_containers_cli/cmds/argo_commands.py#L397-L397: safely access the revision, e.g., app.get("spec", {}).get("source", {}).get("targetRevision", "unknown").
🤖 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 `@src/edge_containers_cli/cmds/argo_commands.py` around lines 320 - 323, Guard
all specified API-resource dictionary accesses in argo_commands.py: at lines
320-323, safely retrieve the app creationTimestamp with .get() and a
datetime.min fallback; at lines 388-391, safely retrieve the manifest
creationTimestamp using .get() or equivalent exception handling; and at line
397, safely resolve the revision through nested .get() calls with "unknown" as
the fallback, preventing extraction-task failures from aborting the TaskGroup.
🤖 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 `@src/edge_containers_cli/cmds/argo_commands.py`:
- Around line 381-387: Update the label discovery logic in the shown
workload-processing loop so label_set becomes True only after successfully
retrieving the description label inside the try block. Leave it false when a
KeyError occurs, allowing subsequent top-level workloads to be checked.

---

Outside diff comments:
In `@src/edge_containers_cli/cmds/argo_commands.py`:
- Around line 320-323: Guard all specified API-resource dictionary accesses in
argo_commands.py: at lines 320-323, safely retrieve the app creationTimestamp
with .get() and a datetime.min fallback; at lines 388-391, safely retrieve the
manifest creationTimestamp using .get() or equivalent exception handling; and at
line 397, safely resolve the revision through nested .get() calls with "unknown"
as the fallback, preventing extraction-task failures from aborting the
TaskGroup.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 05ff7760-8615-4ddf-8f6d-bc655dd33a6e

📥 Commits

Reviewing files that changed from the base of the PR and between 5292dcd and ecfa2a9.

📒 Files selected for processing (2)
  • src/edge_containers_cli/cmds/argo_commands.py
  • tests/data/argocd.yaml

Comment thread src/edge_containers_cli/cmds/argo_commands.py
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • src/edge_containers_cli/cmds/argo_commands.py

Commit: f00c849f0f9c1cce8117ad501836eb93ae69c630

The changes have been pushed to the generic-manifest-fetch branch.

Time taken: 2m 37s

@OCopping
OCopping force-pushed the generic-manifest-fetch branch 2 times, most recently from 5422f47 to 881a892 Compare July 20, 2026 09:47
Also add a taskgroup except* handler
@OCopping
OCopping force-pushed the generic-manifest-fetch branch from 881a892 to 85e92ac Compare July 20, 2026 09:49
@OCopping
OCopping requested review from gilesknap and removed request for gilesknap July 20, 2026 09:57
@OCopping

Copy link
Copy Markdown
Contributor Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

1 similar comment
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@OCopping
OCopping requested a review from gilesknap July 20, 2026 10:55
@OCopping

Copy link
Copy Markdown
Contributor Author

the is_ready flag used to look at readyReplicas, but now looks at both the health status of an Application and for the STOPPED label/flag. Is this everything we need to cover?

@OCopping

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@OCopping
OCopping requested review from gilesknap and removed request for gilesknap July 23, 2026 07:56

@gilesknap gilesknap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oooh this looks good. testing now.

@gilesknap gilesknap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice work. This appears to do the right thing from my tests on a couple of beamlines.

@OCopping
OCopping merged commit d1a3f17 into main Jul 27, 2026
11 checks passed
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.

2 participants