Skip to content

feat: propagate component execution context - #2848

Open
Mikhail Shirkov (shirkevich) wants to merge 23 commits into
codex/helm-lifecycle-actionsfrom
codex/helm-lifecycle-context
Open

feat: propagate component execution context#2848
Mikhail Shirkov (shirkevich) wants to merge 23 commits into
codex/helm-lifecycle-actionsfrom
codex/helm-lifecycle-context

Conversation

@shirkevich

@shirkevich Mikhail Shirkov (shirkevich) commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

what

  • Add a backward-compatible caller context to component execution.
  • Propagate command and scheduler cancellation through direct Helm operations, bulk graph execution, rendering, diffing, delivery, and cluster actions.
  • Preserve fallback behavior for existing callers that do not provide a context.
  • Add cross-provider regression coverage so the shared execution change does not regress Ansible, Kubernetes, container, or emulator components.
  • Add opt-in --dependency-update support to chart-loading operations without hidden network access by default.

This is 3 of 4 in the native Helm lifecycle stack and is based on #2847:

  1. docs: define native Helm release lifecycle #2846 — approved PRD and public contract
  2. feat: implement native Helm release lifecycle controls #2847 — release model, schema, CLI, and Helm actions
  3. feat: propagate component execution context #2848 — execution context, cancellation propagation, and opt-in dependency acquisition
  4. feat: add Helm lifecycle reporting and integration coverage #2849 — operational reporting, documentation, and integration coverage

why

  • Several native Helm paths replaced the caller context with context.Background(), preventing signals and scheduler cancellation from consistently reaching active operations.
  • Context belongs in the shared component execution contract so direct and dependency-ordered execution observe the same cancellation semantics.
  • Missing chart dependencies should be actionable without making repository access or chart-directory mutation implicit.

validation

references

@atmos-pro

atmos-pro Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions github-actions Bot added the size/m Medium size PR label Jul 31, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@shirkevich

Copy link
Copy Markdown
Collaborator Author

CodeRabbit (@coderabbitai) full review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 31, 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
📝 Walkthrough

Walkthrough

The change propagates command contexts through component, lifecycle, graph, Ansible, and Helm execution. Helm supports optional dependency updates, hook manifests, and cancellation-aware release operations. Command masking now honors the nearest changed local flag.

Changes

Context propagation and execution

Layer / File(s) Summary
Context contract and command entrypoints
pkg/component/provider.go, cmd/ansible/*, cmd/container/container.go, cmd/emulator/emulator.go, cmd/helm/helm.go, cmd/kubernetes/kubernetes.go, pkg/component/ansible/*
ExecutionContext stores caller contexts. Command handlers pass Cobra contexts to parsing and provider execution. Ansible process execution receives the caller context.
Lifecycle and graph cancellation
pkg/composition/*, pkg/component/graph*, pkg/component/helm/executor_bulk.go
Lifecycle and graph execution stop dispatch after cancellation. Graph providers receive filtered per-node options and caller contexts.
Helm chart loading and manifest assembly
pkg/component/helm/chart.go, pkg/component/helm/templates.go, pkg/component/helm/testdata/*, pkg/component/helm/helm_test.go, pkg/config/const.go, docs/prd/native-helm-release-lifecycle.md, website/docs/cli/commands/helm/*
Helm validates dependencies, optionally updates missing dependencies, preserves Helm expressions, and includes regular and hook manifests. The dependency_update summary field and CLI documentation are added.
Helm execution and delivery
pkg/component/helm/executor.go, pkg/component/helm/provision.go, related tests
Diff, rendering, baseline retrieval, provisioning, and external delivery derive timeouts from caller contexts and propagate dependency-update settings.
Helm cancellation and release deletion
pkg/component/helm/client.go, lifecycle and client tests
Apply, upgrade, and delete operations check cancellation before setup. Uninstall wait and delete operations receive the caller context. Cancellation and release-state behavior are tested.

Command masking reconciliation

Layer / File(s) Summary
Hierarchical masking override
cmd/root.go, cmd/root_test.go
Persistent pre-run applies global masking, then applies the nearest changed local mask flag. Tests cover root, group, and leaf precedence.

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

Sequence Diagram(s)

sequenceDiagram
  participant CobraCommand
  participant HelmExecutor
  participant ChartLoader
  participant HelmRelease
  participant ExternalTarget
  CobraCommand->>HelmExecutor: pass caller context and dependency-update
  HelmExecutor->>ChartLoader: load and validate chart
  ChartLoader->>ChartLoader: update missing dependencies when enabled
  HelmExecutor->>HelmRelease: render, apply, diff, or delete with context
  HelmExecutor->>ExternalTarget: deliver rendered manifests with context
Loading

Suggested reviewers: osterman

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.63% 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: propagating component execution context.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/helm-lifecycle-context

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: 1

Caution

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

⚠️ Outside diff range comments (1)
pkg/component/helm/client.go (1)

172-193: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Cancel Helm uninstalls during waits.

deleteRelease only checks ctx.Err() before and after client.Run, so cancellation does not stop the Helm action once it starts. action.Uninstall.Run does not accept a context, but WaitOptions can pass contexts to Helm waits. Set client.WaitOptions with kube.WithWaitContext(ctx) and kube.WithWaitForDeleteMethodContext(ctx) for the uninstall waiter.

🤖 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 `@pkg/component/helm/client.go` around lines 172 - 193, The deleteRelease
function must propagate ctx cancellation into the Helm uninstall waits, not only
check it before and after client.Run. Configure client.WaitOptions after
creating the uninstall client with kube.WithWaitContext(ctx) and
kube.WithWaitForDeleteMethodContext(ctx), preserving the existing lifecycle
configuration and error handling.
🤖 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 `@pkg/component/graph.go`:
- Around line 67-69: Update ExecuteGraph’s executeGraphNode error path to check
ctx.Err() after an active node returns; when cancellation is present, wrap the
returned error with errUtils.ErrGraphExecutionCanceled while preserving the
original error for errors.Is matching. Extend the relevant graph tests to assert
both ErrComponentExecutionFailed and ErrGraphExecutionCanceled.

---

Outside diff comments:
In `@pkg/component/helm/client.go`:
- Around line 172-193: The deleteRelease function must propagate ctx
cancellation into the Helm uninstall waits, not only check it before and after
client.Run. Configure client.WaitOptions after creating the uninstall client
with kube.WithWaitContext(ctx) and kube.WithWaitForDeleteMethodContext(ctx),
preserving the existing lifecycle configuration and error handling.
🪄 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: Pro Plus

Run ID: 223c7a47-aaa6-4dc8-9114-7847a2bb6c86

📥 Commits

Reviewing files that changed from the base of the PR and between fc4bb7e and b71f180.

📒 Files selected for processing (16)
  • cmd/helm/helm.go
  • cmd/helm/helm_test.go
  • pkg/component/graph.go
  • pkg/component/graph_test.go
  • pkg/component/helm/client.go
  • pkg/component/helm/client_lifecycle_test.go
  • pkg/component/helm/client_test.go
  • pkg/component/helm/diff_test.go
  • pkg/component/helm/executor.go
  • pkg/component/helm/executor_bulk.go
  • pkg/component/helm/executor_extra_test.go
  • pkg/component/helm/executor_test.go
  • pkg/component/helm/provision.go
  • pkg/component/helm/provision_test.go
  • pkg/component/provider.go
  • pkg/component/provider_test.go

@shirkevich

Copy link
Copy Markdown
Collaborator Author

CodeRabbit (@coderabbitai) full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 33 minutes.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 1, 2026
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.94118% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.76%. Comparing base (0187533) to head (3804ff1).

Files with missing lines Patch % Lines
pkg/component/helm/chart.go 70.90% 8 Missing and 8 partials ⚠️
pkg/component/helm/client.go 71.42% 10 Missing and 2 partials ⚠️
cmd/root.go 71.42% 2 Missing and 2 partials ⚠️
cmd/ansible/version.go 40.00% 3 Missing ⚠️
pkg/component/ansible/executor.go 0.00% 3 Missing ⚠️
pkg/component/ansible/ansible.go 33.33% 2 Missing ⚠️
cmd/ansible/playbook.go 0.00% 1 Missing ⚠️
cmd/container/container.go 50.00% 1 Missing ⚠️
cmd/emulator/emulator.go 66.66% 1 Missing ⚠️
cmd/helm/helm.go 83.33% 1 Missing ⚠️
... and 1 more

❌ Your patch check has failed because the patch coverage (77.94%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                        @@
##           codex/helm-lifecycle-actions    #2848      +/-   ##
================================================================
+ Coverage                         82.75%   82.76%   +0.01%     
================================================================
  Files                              1861     1862       +1     
  Lines                            180834   180982     +148     
================================================================
+ Hits                             149649   149792     +143     
+ Misses                            23361    23357       -4     
- Partials                           7824     7833       +9     
Flag Coverage Δ
unittests 82.76% <77.94%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
errors/errors.go 100.00% <ø> (ø)
pkg/component/graph.go 90.88% <100.00%> (+1.47%) ⬆️
pkg/component/helm/executor.go 82.92% <100.00%> (+0.48%) ⬆️
pkg/component/helm/executor_bulk.go 90.66% <100.00%> (ø)
pkg/component/helm/provision.go 92.68% <100.00%> (ø)
pkg/component/helm/templates.go 82.75% <ø> (-0.30%) ⬇️
pkg/component/provider.go 100.00% <100.00%> (ø)
pkg/composition/executor.go 88.14% <100.00%> (+0.37%) ⬆️
cmd/ansible/playbook.go 37.93% <0.00%> (-1.36%) ⬇️
cmd/container/container.go 77.52% <50.00%> (+0.25%) ⬆️
... and 9 more

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shirkevich

Copy link
Copy Markdown
Collaborator Author

CodeRabbit (@coderabbitai) full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@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

🤖 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 `@pkg/component/helm/client_lifecycle_test.go`:
- Around line 145-154: Extend TestApplyReleaseHonorsCanceledContext by querying
getDeployedManifest after applyRelease returns and asserting the resulting
manifest is empty, while preserving the existing context.Canceled error
assertion. Use the test’s existing action context and release identifiers to
verify that cancellation leaves no deployed release.

In `@pkg/component/provider.go`:
- Around line 49-51: Update every unkeyed component.ExecutionContext literal
passed to provider.Execute in the affected command implementations to keyed
fields, preserving each existing positional value and populating Context through
the established GoContext propagation path. Keep the Context field in
ExecutionContext, and document the struct as keyed-only for external callers so
future additions cannot silently misalign values.
🪄 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: Pro Plus

Run ID: fe627d87-3556-476c-8ca3-db334bcec369

📥 Commits

Reviewing files that changed from the base of the PR and between 3fbac27 and 2d1f2df.

📒 Files selected for processing (16)
  • cmd/helm/helm.go
  • cmd/helm/helm_test.go
  • pkg/component/graph.go
  • pkg/component/graph_test.go
  • pkg/component/helm/client.go
  • pkg/component/helm/client_lifecycle_test.go
  • pkg/component/helm/client_test.go
  • pkg/component/helm/diff_test.go
  • pkg/component/helm/executor.go
  • pkg/component/helm/executor_bulk.go
  • pkg/component/helm/executor_extra_test.go
  • pkg/component/helm/executor_test.go
  • pkg/component/helm/provision.go
  • pkg/component/helm/provision_test.go
  • pkg/component/provider.go
  • pkg/component/provider_test.go

Comment thread pkg/component/helm/client_lifecycle_test.go
Comment thread pkg/component/provider.go
@shirkevich

Copy link
Copy Markdown
Collaborator Author

CodeRabbit (@coderabbitai) full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 47 minutes.

@shirkevich

Copy link
Copy Markdown
Collaborator Author

CodeRabbit (@coderabbitai) full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 9 minutes.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/l Large size PR stacked Stacked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant