Skip to content

ZEP-0026: Enhanced State Management - #27

Open
Racer159 wants to merge 13 commits into
zarf-dev:mainfrom
Racer159:26-enhanced-state-management
Open

Racer159 wants to merge 13 commits into
zarf-dev:mainfrom
Racer159:26-enhanced-state-management

Conversation

@Racer159

Copy link
Copy Markdown
Contributor
  • One-line PR description: Enhance Zarf's State management and tracking of resources/packages/components.
  • Other comments:

Signed-off-by: Wayne Starr <me@racer159.com>
@Racer159 Racer159 mentioned this pull request Apr 29, 2025
3 tasks
Signed-off-by: Wayne Starr <me@racer159.com>
@brandtkeller brandtkeller moved this to Triage in Zarf Oct 24, 2025
Signed-off-by: Wayne Starr <me@racer159.com>
@Racer159

Racer159 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Updated this proposal to account for where Zarf is today and looking to address concerns from zarf-dev/zarf#2992 (zarf-dev/zarf#4211) / zarf-dev/zarf#4969 / zarf-dev/zarf#4182 (zarf-dev/zarf#5007)

Signed-off-by: Wayne Starr <me@racer159.com>

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

Excited to see this develop, I think there are a lot of value adds. Some comments around UX and potential drawbacks.

Comment thread 0026-enhanced-state-management/README.md Outdated
Comment thread 0026-enhanced-state-management/README.md Outdated
Comment thread 0026-enhanced-state-management/README.md
Comment thread 0026-enhanced-state-management/README.md Outdated
Comment thread 0026-enhanced-state-management/README.md
Comment thread 0026-enhanced-state-management/README.md Outdated
@github-project-automation github-project-automation Bot moved this from Triage to In progress in Zarf Jul 6, 2026
Signed-off-by: Wayne Starr <me@racer159.com>

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

leaving one thought as I'm reading through

Comment thread 0026-enhanced-state-management/README.md

@jasonwashburn jasonwashburn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For SDK applications like the Tofu provider, I think we should consider persisting the actual successful deploy configuration itself in addition to its digest. ConfigDigest can tell us whether two configurations differ, but it cannot tell us what deployment-time configuration and values are currently represented by cluster state. Without the config itself, the tofu provider cant accurately import an existing package and hydrate its resource state or detect drift/update tofu state to show an accurate plan without making some assumptions.

I suggest adding a single top-level DeployConfig and matching ConfigDigest to DeployedPackage which represents the latest successful deployment. Failed or cancelled deploy attempts should remain visible through PackageEvent.ConfigDigest, but probably shouldn't replace the config representing the package's current installed state.

Optionally we could store each event's full config alongside PackageEvent.ConfigDigest, but I can't currently think of any immediately useful need for consuming that history...so it's probably not worth the additional Secret growth.

Signed-off-by: Wayne Starr <me@racer159.com>
Signed-off-by: Wayne Starr <me@racer159.com>
Signed-off-by: Wayne Starr <me@racer159.com>
AustinAbro321
AustinAbro321 previously approved these changes Aug 7, 2026

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

LGTM

Signed-off-by: Wayne Starr <me@racer159.com>
Signed-off-by: Wayne Starr <me@racer159.com>
Signed-off-by: Wayne Starr <me@racer159.com>
AustinAbro321
AustinAbro321 previously approved these changes Aug 20, 2026
- Redeploy (when the source is online - e.g. https/oci)
- Report deploy state / progress
- Report remove state / progress
- Resume multi-package deployment (identified by package digest + config digest)

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.

I think the requirements laid out can be used to accomplish this goal but I have concerns about including it as a goal explicitly. Primarily on the basis of the Zarf project focusing on package primitives and the scope of single package operations - and enabling other tooling to build more complex handling/orchestration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed it to just focus on identifying if this is the same package deployment instead of having the multi package wording.

Signed-off-by: Wayne Starr <me@racer159.com>

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

lgtm - added a thought after giving this another pass with RBAC considerations but otherwise believe it to be well scoped.


##### Image reconciliation

When `images` is selected, Zarf diffs each changed or removed component's previously deployed `Images` against the new component's `Images` (both plain `[]string` image references on `v1alpha1.ZarfComponent`). An image present in the old set but not the new one is a pruning candidate only if no other deployed package still needs it: Zarf calls `Cluster.GetDeployedZarfPackages` to list every `DeployedPackage` secret in the cluster and checks whether the candidate image appears in any other package's component images. If nothing else references it, both tags Zarf pushes for that image are removed from the internal registry - the plain tag and the CRC-32-suffixed tag the Zarf agent uses for transparent redirection (see `images/push.go`). If another package still references it, both tags are left alone.

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.

This idea is still sitting in a draft locally - but I want to at least callout the change in potential RBAC scope here. charts and components are scoped to a single package - where pruning images is going to require privileges to read all state secrets.

I haven't amended the namespace ZEP with this context yet so I wouldn't block on it - but I am trying to look for patterns we may want to start to separate from expectations.


Today, if a `zarf package deploy` or `zarf package remove` is interrupted, the latest package `PackageEvent`/component `LastEvent` (once this proposal exists) can be left at `InProgress` indefinitely, with nothing to correct it afterward.

On a controlled stop - Zarf catching `SIGINT`/`SIGTERM` via a cancellable `context.Context` (e.g. `signal.NotifyContext`) - Zarf will attempt to append a `Cancelled` package event and set the in-progress component's `LastEvent` to `Cancelled` before exiting. This is best-effort: an ungraceful termination (`SIGKILL`, node crash, power loss) gives Zarf no opportunity to run any code, so the latest event can still be left at `InProgress` - see [Risks and Mitigations](#risks-and-mitigations).

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.

in support of this where possible - I believe we started down this path with chart installations. (no action)

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

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants