Skip to content

feat: implement native Helm release lifecycle controls - #2847

Open
Mikhail Shirkov (shirkevich) wants to merge 21 commits into
codex/helm-lifecycle-prdfrom
codex/helm-lifecycle-actions
Open

feat: implement native Helm release lifecycle controls#2847
Mikhail Shirkov (shirkevich) wants to merge 21 commits into
codex/helm-lifecycle-prdfrom
codex/helm-lifecycle-actions

Conversation

@shirkevich

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

Copy link
Copy Markdown
Collaborator

what

  • Implement the approved hierarchical native Helm release policy with release-wide defaults and operation-specific install, upgrade, and delete overlays.
  • Deep-merge the complete release tree through stack defaults, abstract/base inheritance, and the concrete component before selecting an operation.
  • Apply only explicitly supplied CLI lifecycle flags after operation selection, at highest precedence.
  • Map install uninstall-on-failure, upgrade rollback and independent cleanup, wait strategy and Jobs, per-operation timeout, history, chart hooks, and CRD policy into Helm 4 actions.
  • Enforce strict nested schemas and reject misplaced, unknown, or inapplicable fields and flags.
  • Preserve inherited Helm values when a bare values: key decodes to null, keep inline and values_files template strings consistent, propagate top-level secrets, and honor command-local --mask=false.

This is 2 of 4 in the native Helm lifecycle stack and is based on #2846:

  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 and cancellation propagation
  4. feat: add Helm lifecycle reporting and integration coverage #2849 — operational reporting, documentation, and integration coverage

why

  • One flat policy cannot express a slow first install and a shorter upgrade or delete timeout.
  • Stack configuration must remain declarative while explicit incident-time CLI flags remain authoritative.
  • Operation-scoped enums make invalid combinations fail clearly instead of being silently ignored.

validation

  • 134 Helm package tests.
  • 59 Helm CLI tests.
  • 202 manifest-schema tests.
  • 116 affected stack-processing tests covering type defaults, nested inheritance, and concrete overrides.
  • A real multi-component POC converges with the hierarchical release tree, including distinct install and upgrade timeouts and upgrade rollback plus cleanup policy.
  • Strict schema coverage, git diff --check, and generic fixture-name audit pass.

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

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@mergify mergify Bot added the stacked Stacked label Jul 31, 2026
@mergify
mergify Bot temporarily deployed to screengrabs July 31, 2026 23:21 Inactive
@shirkevich Mikhail Shirkov (shirkevich) changed the title codex/helm lifecycle actions feat: implement native Helm release lifecycle controls Jul 31, 2026
@shirkevich Mikhail Shirkov (shirkevich) added the minor New features that do not break anything label Jul 31, 2026
Comment thread pkg/component/helm/lifecycle.go Fixed
@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

Helm now supports configurable release lifecycle policies across schemas, stack inheritance, CLI flags, lifecycle validation, and install, upgrade, and uninstall execution. Dry-run handling, lifecycle summaries, external-target validation, and related tests were added.

Changes

Helm lifecycle support

Layer / File(s) Summary
CLI lifecycle flags and extraction
cmd/helm/helm.go, cmd/helm/helm_test.go, pkg/config/const.go, errors/errors.go
Apply, deploy, and delete expose lifecycle flags. Explicit values are converted to typed Helm configuration fields. Lifecycle validation errors are defined.
Manifest and stack schemas
pkg/datafetcher/schema/..., pkg/datafetcher/schema_helm_lifecycle_validation_test.go, pkg/datafetcher/schema_section_coverage_test.go
Schemas define native Helm components, repositories, lifecycle fields, wait strategies, overrides, and validation rules.
Stack lifecycle inheritance
internal/exec/stack_processor_*.go
Global Helm lifecycle values and stack overrides flow into component processing. Component values override base and global values.
Lifecycle policy resolution
pkg/component/helm/lifecycle.go, pkg/component/helm/values.go, pkg/component/helm/chart.go, pkg/component/helm/lifecycle_test.go
Canonical fields, aliases, defaults, CLI overrides, warnings, typed decoding, and validation produce a resolved lifecycle policy.
Lifecycle-aware release execution
pkg/component/helm/client.go, pkg/component/helm/executor.go, pkg/component/helm/provision.go, pkg/component/helm/*_test.go
Install, upgrade, and uninstall actions use the resolved policy. Dry-run state, operation results, lifecycle summaries, and external-target validation are handled.

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

Sequence Diagram(s)

sequenceDiagram
  participant HelmCommand
  participant HelmExecutor
  participant HelmClient
  participant Kubernetes
  HelmCommand->>HelmExecutor: lifecycle flags and operation
  HelmExecutor->>HelmClient: resolved chartSpec and dryRun
  HelmClient->>Kubernetes: install, upgrade, or uninstall release
  Kubernetes-->>HelmClient: releaseActionResult
Loading

Suggested reviewers: osterman

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.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
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 summarizes the PR's main change: native Helm release lifecycle controls.
✨ 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-actions

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 (2)
pkg/datafetcher/schema/stacks/stack-config/1.0.json (1)

855-862: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract a shared wait_strategy enum definition.

This schema repeats the wait_strategy enum (watcher, hookOnly, legacy) in the "helm" defaults block and in "helm_component_manifest". pkg/datafetcher/schema/atmos/manifest/1.0.json avoids this by defining helm_wait_strategy once and referencing it with $ref in both places. Apply the same pattern here to keep the two copies from diverging.

♻️ Proposed refactor
   "definitions": {
+    "helm_wait_strategy": {
+      "title": "helm_wait_strategy",
+      "description": "Helm 4 release wait strategy",
+      "type": "string",
+      "enum": ["watcher", "hookOnly", "legacy"]
+    },
     "helm_repository": {

Then, in both the "helm" and "helm_component_manifest" definitions:

-            "wait_strategy": {
-              "type": "string",
-              "enum": [
-                "watcher",
-                "hookOnly",
-                "legacy"
-              ]
-            },
+            "wait_strategy": {
+              "$ref": "`#/definitions/helm_wait_strategy`"
+            },

Also applies to: 998-1005

🤖 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/datafetcher/schema/stacks/stack-config/1.0.json` around lines 855 - 862,
Define a shared `helm_wait_strategy` enum schema containing `watcher`,
`hookOnly`, and `legacy`, then replace the duplicated `wait_strategy` enum
definitions in both the `helm` defaults block and `helm_component_manifest` with
`$ref` references to it, matching the pattern used in the atmos manifest schema.
cmd/helm/helm.go (1)

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

Keep Helm history defaults in one place.

cmd/helm/helm.go uses defaultHelmHistoryMax = 10, while pkg/component/helm/lifecycle.go uses a separate defaultHelmMaxHistory = 10. Use a shared constant for the CLI flag and lifecycle default so future changes do not drift between help text, --history-max behavior, and the lifecycle resolver’s applied policy.

🤖 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 `@cmd/helm/helm.go` at line 165, Consolidate the duplicate Helm history
defaults by defining one shared constant and using it for both the
cmd/helm/helm.go history-max flag and the pkg/component/helm/lifecycle.go
defaultHelmMaxHistory resolver behavior. Remove the separate
defaultHelmHistoryMax and defaultHelmMaxHistory definitions while preserving the
current value and CLI/help 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 `@pkg/component/helm/client_test.go`:
- Around line 59-97: Upgrade the pinned helm.sh/helm/v4 dependency to a release
containing the RollbackOnFailure WaitStrategy fix, ensuring
configureInstallLifecycle and configureUpgradeLifecycle no longer allow the
internal rollback/uninstall path to fail with “unknown wait strategy.”

In `@pkg/component/helm/executor.go`:
- Around line 164-172: Update the lifecycle warning loop in the apply/delete
operation path to send each warning through the command UI’s stderr/status
output mechanism instead of log.Warn. Preserve the warning message and its
field/code context using the established ui.Write* or equivalent UI symbol
available in the surrounding executor flow.

---

Nitpick comments:
In `@cmd/helm/helm.go`:
- Line 165: Consolidate the duplicate Helm history defaults by defining one
shared constant and using it for both the cmd/helm/helm.go history-max flag and
the pkg/component/helm/lifecycle.go defaultHelmMaxHistory resolver behavior.
Remove the separate defaultHelmHistoryMax and defaultHelmMaxHistory definitions
while preserving the current value and CLI/help behavior.

In `@pkg/datafetcher/schema/stacks/stack-config/1.0.json`:
- Around line 855-862: Define a shared `helm_wait_strategy` enum schema
containing `watcher`, `hookOnly`, and `legacy`, then replace the duplicated
`wait_strategy` enum definitions in both the `helm` defaults block and
`helm_component_manifest` with `$ref` references to it, matching the pattern
used in the atmos manifest schema.
🪄 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: 2dcfc3bd-8fdb-4470-b0cc-9df9fd9be979

📥 Commits

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

📒 Files selected for processing (27)
  • cmd/helm/helm.go
  • cmd/helm/helm_test.go
  • errors/errors.go
  • internal/exec/stack_processor_merge.go
  • internal/exec/stack_processor_merge_test.go
  • internal/exec/stack_processor_process_stacks.go
  • internal/exec/stack_processor_process_stacks_helpers.go
  • internal/exec/stack_processor_process_stacks_helpers_extraction.go
  • internal/exec/stack_processor_process_stacks_helpers_test.go
  • internal/exec/stack_processor_process_stacks_test.go
  • pkg/component/helm/chart.go
  • pkg/component/helm/client.go
  • pkg/component/helm/client_lifecycle_test.go
  • pkg/component/helm/client_test.go
  • pkg/component/helm/executor.go
  • pkg/component/helm/executor_extra_test.go
  • pkg/component/helm/executor_test.go
  • pkg/component/helm/lifecycle.go
  • pkg/component/helm/lifecycle_test.go
  • pkg/component/helm/provision.go
  • pkg/component/helm/provision_test.go
  • pkg/component/helm/values.go
  • pkg/config/const.go
  • pkg/datafetcher/schema/atmos/manifest/1.0.json
  • pkg/datafetcher/schema/stacks/stack-config/1.0.json
  • pkg/datafetcher/schema_helm_lifecycle_validation_test.go
  • pkg/datafetcher/schema_section_coverage_test.go

Comment thread pkg/component/helm/client_test.go
Comment thread pkg/component/helm/executor.go Outdated
@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 34 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.

@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 48 minutes.

@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)
pkg/component/helm/lifecycle.go (1)

97-105: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a warning for the silent rollback-driven wait strategy override.

validateAndDeriveLifecycle changes WaitStrategy from HookOnlyStrategy to StatusWatcherStrategy whenever RollbackOnFailure is true. This change has no observable trace: no lifecycleWarning is appended, unlike warningAtomicDeprecated, warningWaitIgnored, warningWaitBoolean, and warningTimeoutMigration.

A user who sets wait_strategy: hookOnly explicitly, together with rollback_on_failure: true, gets a different wait strategy than requested, with no signal in resolution.Warnings to explain why. Add a warning code for this derivation so the change is visible in lifecycle summaries and logs.

♻️ Proposed fix to surface the derived override
+const warningWaitStrategyDerived lifecycleWarningCode = "wait_strategy_derived_from_rollback"
+
 func validateAndDeriveLifecycle(resolution *releaseLifecycleResolution) error {
 	if resolution.Policy.RollbackOnFailure && resolution.Policy.WaitStrategy == kube.HookOnlyStrategy {
 		resolution.Policy.WaitStrategy = kube.StatusWatcherStrategy
+		resolution.Warnings = append(resolution.Warnings, lifecycleWarning{
+			Code:    warningWaitStrategyDerived,
+			Field:   cfg.HelmWaitStrategySectionName,
+			Message: "helm wait_strategy was changed to 'watcher' because rollback_on_failure requires monitoring release status",
+		})
 	}
 	if resolution.Policy.WaitForJobs && resolution.Policy.WaitStrategy == kube.HookOnlyStrategy {
 		return errUtils.ErrHelmWaitForJobsRequiresWait
 	}
 	return nil
 }
🤖 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/lifecycle.go` around lines 97 - 105, Add a dedicated
lifecycle warning code for the rollback-driven wait-strategy override, following
the existing warning symbols such as warningAtomicDeprecated and
warningTimeoutMigration. In validateAndDeriveLifecycle, append that warning to
resolution.Warnings whenever RollbackOnFailure changes HookOnlyStrategy to
StatusWatcherStrategy, while preserving the existing wait-for-jobs validation
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 `@cmd/helm/helm.go`:
- Around line 157-175: Update the duplicated --wait help descriptions in
addLifecycleOperationFlags for both apply and delete to document the accepted
legacy boolean values true and false alongside watcher, hookOnly, and legacy;
preserve the existing resolver behavior and default watcher selection.

In `@pkg/component/helm/client.go`:
- Around line 74-75: Update the Helm action failure returns in the history
inspection branch and the corresponding lines around the later Helm action
handling to wrap distinct static sentinel errors from errors/errors.go, while
preserving the Helm error as the wrapped cause and existing contextual messages.
Reuse an existing sentinel where appropriate or add clearly named static errors,
ensuring callers can use errors.Is() to identify each failure category.

---

Nitpick comments:
In `@pkg/component/helm/lifecycle.go`:
- Around line 97-105: Add a dedicated lifecycle warning code for the
rollback-driven wait-strategy override, following the existing warning symbols
such as warningAtomicDeprecated and warningTimeoutMigration. In
validateAndDeriveLifecycle, append that warning to resolution.Warnings whenever
RollbackOnFailure changes HookOnlyStrategy to StatusWatcherStrategy, while
preserving the existing wait-for-jobs validation 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3769a387-c520-4d4f-bf22-166e16bf3f3f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b7cf18 and 3fbac27.

📒 Files selected for processing (27)
  • cmd/helm/helm.go
  • cmd/helm/helm_test.go
  • errors/errors.go
  • internal/exec/stack_processor_merge.go
  • internal/exec/stack_processor_merge_test.go
  • internal/exec/stack_processor_process_stacks.go
  • internal/exec/stack_processor_process_stacks_helpers.go
  • internal/exec/stack_processor_process_stacks_helpers_extraction.go
  • internal/exec/stack_processor_process_stacks_helpers_test.go
  • internal/exec/stack_processor_process_stacks_test.go
  • pkg/component/helm/chart.go
  • pkg/component/helm/client.go
  • pkg/component/helm/client_lifecycle_test.go
  • pkg/component/helm/client_test.go
  • pkg/component/helm/executor.go
  • pkg/component/helm/executor_extra_test.go
  • pkg/component/helm/executor_test.go
  • pkg/component/helm/lifecycle.go
  • pkg/component/helm/lifecycle_test.go
  • pkg/component/helm/provision.go
  • pkg/component/helm/provision_test.go
  • pkg/component/helm/values.go
  • pkg/config/const.go
  • pkg/datafetcher/schema/atmos/manifest/1.0.json
  • pkg/datafetcher/schema/stacks/stack-config/1.0.json
  • pkg/datafetcher/schema_helm_lifecycle_validation_test.go
  • pkg/datafetcher/schema_section_coverage_test.go

Comment thread cmd/helm/helm.go Outdated
Comment thread pkg/component/helm/client.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/l Large size PR stacked Stacked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants