Skip to content

Conversation

brandtkeller
Copy link
Member

@brandtkeller brandtkeller commented Sep 11, 2025

Description

This PR adds state tracking for component Installed Charts.

There is currently a gap in the deploy lifecycle where a user attempts to deploy a package - where a component chart subsequently fails to become healthy - and the deploy fails.

Chart State

This leaves users in a state where If this is an initial deploy - no installed charts are recorded for the component - and thus they cannot be removed with zarf package remove. You then have to cleanup resources with helm (not the embedded version) or kubectl (which is messy). This is a very common process for package development.

Installed Chart state is not strictly required to solve this - but knowing which of the charts of a component failed on subsequent updates - outside of the CLI logs - could be a future value add.

Context Cancellation

When the scenario highlighted above occurs - developers may not want to wait for the timeout (up to multiple minutes) to occur. Given a common scenario - errimagepull occurs - the package developer will very quickly realize that they need to add a missing or incorrect image definition to a component. They (at least myself) will reach for ctrl+c to cancel deploy.

The above changes for tracking failure will not handle this case natively. The context cancellation will propagate to the client-go operations and will not perform the recording in the package secret.

This PR additionally includes context handling to ensure the recording can finish before exiting gracefully.

Related Issue

Fixes #4171

Checklist before merging

Signed-off-by: Brandt Keller <brandt.keller@defenseunicorns.com>
Copy link

netlify bot commented Sep 11, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 7ec78cc
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/68cc750c2d6dee0009c63575

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 42.10526% with 44 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pkg/packager/deploy.go 0.00% 36 Missing ⚠️
src/internal/packager/helm/chart.go 0.00% 8 Missing ⚠️
Files with missing lines Coverage Δ
src/pkg/state/state.go 33.00% <100.00%> (+12.53%) ⬆️
src/internal/packager/helm/chart.go 1.29% <0.00%> (ø)
src/pkg/packager/deploy.go 0.00% <0.00%> (ø)
🚀 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.

Signed-off-by: Brandt Keller <brandt.keller@defenseunicorns.com>
Signed-off-by: Brandt Keller <brandt.keller@defenseunicorns.com>
@brandtkeller brandtkeller marked this pull request as ready for review September 13, 2025 04:27
@brandtkeller brandtkeller requested review from a team as code owners September 13, 2025 04:27
Copy link
Contributor

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

I think this will solve an important pain point for users. A few initial comments and suggestions

Signed-off-by: Brandt Keller <brandt.keller@defenseunicorns.com>
Signed-off-by: Brandt Keller <brandt.keller@defenseunicorns.com>
Signed-off-by: Brandt Keller <brandt.keller@defenseunicorns.com>
existingCharts []InstalledChart
installedCharts []InstalledChart
expectedCharts []InstalledChart
}{
Copy link
Contributor

Choose a reason for hiding this comment

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

nit but I think partial should be a field on this table test as well

Copy link
Member Author

Choose a reason for hiding this comment

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

fair - partial has no functional purpose yet - but wanted to set us up for prune without having to make a breaking change.

lookup starts with the existing state and then adds each chart that was installed by the component. For prune - partial represents that we won't want to mark a release as untracked because deploy may have failed before it was deployed.

Open to removing it - but low overhead.

Copy link
Contributor

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

Overall I think these changes look good, but I'd like to see an e2e test in 41_remove_test.go for this behavior

@brandtkeller
Copy link
Member Author

Overall I think these changes look good, but I'd like to see an e2e test in 41_remove_test.go for this behavior

Added a test - great call.

Copy link
Contributor

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

This should make a core user flow much improved, nice work. Reminder to remove the tracking info from the PR description

@brandtkeller brandtkeller added this pull request to the merge queue Sep 25, 2025
Merged via the queue into main with commit 39f4635 Sep 25, 2025
27 checks passed
@brandtkeller brandtkeller deleted the 4171_remove_state branch September 25, 2025 23:20
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.

Zarf package remove fails to remove unsuccessful helm releases
2 participants