Skip to content

fix(chart, e2e): the seeded MeshConfig is a hook, so helm rollback to a release's first revision works (#1471) - #1513

Merged
bpalermo merged 9 commits into
mainfrom
fix/1471-rollback-first-revision
Oct 9, 2026
Merged

bpalermo merged 9 commits into
mainfrom
fix/1471-rollback-first-revision

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Closes #1471

An agent wrote this pull request.

What was wrong

The chart seeds the default MeshConfig once (a lookup skips it when one is live) and never renders it again, so that operators own it. As an object of the release it was in the manifest of the one revision that created it (normally the first; a later one when an upgrade found the object absent), in no later manifest, and still live (helm.sh/resource-policy: keep). helm rollback to that revision, helm rollback <release> 1 on nearly every release, then fails:

Error: no MeshConfig with the name "default" found

Measured (kind, Kubernetes v1.35.8, Helm 3.18.4, the chart on main): install, an edit of the MeshConfig, upgrade, helm rollback aether 1. Revision 1's manifest holds one MeshConfig, revision 2's none; the rollback fails with the message above and leaves the release failed at revision 3; helm rollback aether 2 then succeeds.

Read in Helm 3.18.4 (pkg/kube/client.go, Update): for each object of the target manifest that is live, Helm takes the copy in the current manifest as the starting point of its patch and returns this error when there is none. helm upgrade does not hit it because it first adopts live objects that carry the release's ownership annotations; helm rollback has no such step. No hook ordering is involved.

The fix

The seed is a Helm hook, helm.sh/hook: pre-install,pre-upgrade, so it is in no revision's manifest. The lookup guard is unchanged: the seed is rendered only when no MeshConfig is live.

  • pre-, not post-: the agent pod stays in ContainerCreating until the controller has projected the MeshConfig into a ConfigMap, so under --wait a post-install hook would never run.
  • pre-upgrade as well: an upgrade that finds the MeshConfig absent seeds it, as before.
  • No rollback event. On a rollback Helm runs the hooks stored with the target revision, whatever is live; a seed with a rollback event would be created or applied over the operator's MeshConfig. A template test matches the annotations block whole for this reason.
  • helm.sh/hook-delete-policy: never, so that the hook deletes nothing. never is not a policy Helm knows; see the next section for why it is there and not hook-failed.
  • One exception, deliberately left as it was: a pre-install hook runs before any object of the release exists, so it cannot create a MeshConfig in a namespace that the same revision creates. On that one revision (the edge's MeshConfig with edge.namespaceCreate=true, its default once the edge is on; the control plane's with namespace.create=true) the seed is still a release object, and that revision still cannot be rolled back to once a later one exists. Rendering it as a hook there would fail the install. See "Not fixed" below.

helm.sh/resource-policy: keep stays on the object: it is what protects it in the exception above, and on objects older charts created.

The hook's delete policy (review round 2)

A hook with no helm.sh/hook-delete-policy gets Helm's default, before-hook-creation: Helm deletes the live object of that name just before it creates the hook's. The lookup only says the MeshConfig was absent when the chart was rendered; the hook runs later. The review asked for hook-failed. Each candidate was measured on kind (Kubernetes v1.35.8, the real chart and images, the controller running) with Helm 3.18.4 and with Helm 4.2.0, which is the version this repository's Bazel toolchain pins. The race was made deterministic with a scratch copy of the chart holding one more pre-upgrade hook of a lower weight (a Pod that sleeps 15 s): the MeshConfig is deleted, the upgrade starts, and once the sleeper is running (so the chart is rendered, with the seed in it) a MeshConfig with its own spec is created with kubectl create.

Case no policy (this pull request before) hook-succeeded hook-failed never (chosen)
a. fresh install seeded, in helm get hooks, not in the manifest install "succeeds" and the seed is deleted as soon as it is created: unusable, not measured further as no policy as no policy
b. upgrade, object present hook not rendered (helm get hooks of that revision holds no MeshConfig); same UID, edit kept same same
c. upgrade, object absent seeded again, as a hook deleted again same same
d. the race, Helm 3.18.4 (and Helm 4.2.0 on a release it applies client side) the object is deleted and replaced by the seed; helm exits 0, release deployed exit 1, meshconfigs.config.aether.io "default" already exists; object untouched (same UID, spec, no Helm annotation) identical to hook-failed
d. the race, Helm 4.2.0 server-side apply (its default for a release it installed) deleted and replaced, exit 0 exit 0; same UID and spec; the object gains the chart's labels and the hook annotations (field manager helm) identical to hook-failed
d. the race, Helm 4 server-side, a non-empty seed whose fields the object does not set (meshConfig.proxy.tracingEnabled=true over an object with only accessLogsEnabled: true; review round 3) (deleted and replaced) not measured exit 0; same UID; the seed is merged in: the object ends with both fields set. With Helm 3.18.4: exit 1 "already exists", object untouched
d. the race, Helm 4 server-side, seed and object disagree on a field deleted and replaced, exit 0 exit 1, Apply failed with 1 conflict; object untouched identical
d+e. the race, Helm 4 server-side, and the wait after the apply fails (an identity that may not list MeshConfigs) deleted and replaced, exit 1 the operator's object is deleted and nothing is left, exit 1 exit 1; object kept (same UID, spec)
e. hook refused at admission, object absent exit 1; nothing created, nothing deleted same same
e. created, then the wait fails, object absent (Helm 4 only: Helm 3 does not wait on a MeshConfig) exit 1; the seed stays exit 1; the seed is deleted exit 1; the seed stays
f. rollback to every revision in the history, the seeding ones and those after a failed upgrade included all succeed; same UID, edit kept same same
g. uninstall object left behind left behind left behind

After every failed upgrade above the release is failed at a new revision with the previous revision still deployed, and a plain re-run of the same helm upgrade succeeds (the object is live, so the seed is not rendered); in the hook-failed row where the object was deleted, the re-run seeds the default.

Read in Helm (pkg/action/hooks.go, 3.18.4 and 4.2.0): the annotation's values are stored as given and compared with the three known policies, so any value turns the default off and an unknown one matches no deletion step. hook-failed is applied only when the wait after a successful creation fails. Helm 3 creates client side, so that object is always the seed, and does not wait on a MeshConfig at all. Helm 4 applies hooks server side, an apply over an existing object succeeds, and the object deleted after a failed wait is then the operator's.

The choice: never. An upgrade that fails loudly and is fixed by running it again is better than a silent replacement, and both hook-failed and never give that. But hook-failed keeps one measured path that deletes the operator's object, and never has none. What never costs is that it relies on Helm ignoring a value it does not know, which is read in the source of both versions and measured, not documented. helm lint --strict passes with it on both. If a later Helm rejects or reinterprets it, the template tests (rendered with the pinned Helm) and the new e2e leg fail first. If the owner prefers the documented value, it is a one-word change in two templates and one test constant; the trade is the row marked d+e.

Render, before and after (chart version held equal, --set controller.webhook.spire=true)

Values Difference
default the MeshConfig document moves from the manifest to the hooks section and gains two annotation lines; nothing else
edge.enabled=true the same for the control plane's MeshConfig; the edge's (namespace made by the chart) is byte-identical
edge.enabled=true, edge.namespaceCreate=false both MeshConfigs become hooks
meshConfig.createDefault=false, edge.enabled=true byte-identical
   annotations:
+    helm.sh/hook: pre-install,pre-upgrade
+    helm.sh/hook-delete-policy: never
     helm.sh/resource-policy: keep

No pod template changes.

What an operator sees on upgrade

Nothing rolls and nothing in the cluster changes: the MeshConfig is live, so it is not rendered, as before.

Measured on kind, a release installed and upgraded by the chart on main, then upgraded to this chart: the six workloads keep generation=1, the MeshConfig keeps its UID, generation and the edit.

  • A release first installed with 2.4.24 or later can be rolled back to any revision, the first included (measured, and asserted by the e2e leg).
  • A release an older chart seeded keeps that revision as stored (usually revision 1), so the upgrade does not repair it: that one revision still cannot be a rollback target. Measured on the same release: rollback to revision 2 (old chart) and to revision 3 (this chart) succeed in both directions; rollback to revision 1 fails as before. The runbook gives the way round, also measured: helm upgrade to revision 1's chart with revision 1's values (helm get values --revision 1 -o yaml, passed with -f), which also recovers a release the failed rollback left failed.
  • helm get manifest no longer lists the MeshConfig (helm get hooks does, on the revision that seeded it), and the object carries no meta.helm.sh/release-* annotations. helm uninstall leaves it behind, as it left the kept object behind (measured).
  • helm install --no-hooks seeds no MeshConfig.
  • An upgrade that is seeding a MeshConfig (none was live when it started) and finds one when the hook runs fails with Error: UPGRADE FAILED: pre-upgrade hooks failed: ... meshconfigs.config.aether.io "default" already exists. Nothing of the release has changed at that point (pre-upgrade hooks run first) and the MeshConfig is untouched. Run the same command again. With Helm 4 and server-side apply the upgrade goes through instead and the object gains the chart's labels and hook annotations. The runbook section has both.

Also measured with this chart on kind: a fresh helm upgrade --install --wait completes (19 s); a deleted MeshConfig is seeded again by the next upgrade, as a hook; with the edge on and its namespace made by the operator, both MeshConfigs are hooks and rollback to revision 1 succeeds.

Tests, red first

Template tests in charts/aether/BUILD.bazel, run against the templates on main before the fix: 4 fail, 4 pass.

Test On main Here
aether_meshconfig_seed_is_a_hook_test (default) FAILED passes
aether_meshconfig_seed_hook_carries_the_seed_values_test (operator override) FAILED passes
aether_edge_meshconfig_seed_is_a_hook_test FAILED passes
aether_edge_meshconfig_seed_created_namespace_test FAILED passes
aether_meshconfig_seed_off_{default,edge}_test (off switch) passes passes
aether_meshconfig_seed_created_namespace_test (guard) passes passes
aether_meshconfig_seed_is_the_only_hook_test (guard) passes passes

e2e: e2e/first-install.sh gets leg v-a after the upgrade. It edits the MeshConfig, runs helm rollback aether 1 and helm rollback aether 2, and asserts the release is deployed each time, the MeshConfig is the same object with the edit in it, and no revision's manifest holds a MeshConfig. Then it deletes the MeshConfig, upgrades, and asserts it is seeded again outside the manifest and that a rollback to that revision leaves it alone. Run locally with this branch's script against the charts on main:

==> v-a. helm rollback to the release's first revision, and forward again (#1471)
  ✗ helm rollback aether 1 failed: Error: no MeshConfig with the name "default" found

and against this branch, where the whole suite passes (the legs before and after v-a included):

==> v-a. helm rollback to the release's first revision, and forward again (#1471)
  ✓ rolled back to revision 1 (revision 3, deployed) and to revision 2 (revision 4, deployed)
  ✓ the MeshConfig is the same object (uid b3a7bac5-…) and kept the operator's edit
  ✓ no revision's manifest holds a MeshConfig
  ✓ every workload is Ready (after the rollbacks)
  ✓ a deleted MeshConfig is seeded again by the next upgrade (uid 105dc74f-…); that revision can be rolled back to, and the rollback leaves the object alone

Round 2 (the delete policy). The four tests marked FAILED above match the annotations block whole; with helm.sh/hook-delete-policy: never added to what they expect and the templates not yet changed, the same four failed again (191 pass, 4 fail), and they pass with the templates changed. The two "created namespace" tests also hold that a seed rendered as a release object carries no hook annotation of any kind.

e2e/first-install.sh gets leg v-a2, the race of row d as a regression test: a copy of the chart with a slow pre-upgrade hook ahead of the seed (a Pod that sleeps, on kube-proxy's image, which every node has), a MeshConfig created while that hook runs, and the assertion that it is the same object with its spec afterwards. It accepts either honest outcome (the upgrade fails on "already exists" and then succeeds when run again, or goes through) and fails on a deletion or a replacement. With this branch's script against the chart as it was before this round:

==> v-a2. a MeshConfig created between the render and the seed hook is not deleted (#1471)
  ✗ the upgrade deleted the MeshConfig created during it and put the seed in its place (uid de69aa55-… -> 80584a48-…, helm exit 0)

and against this branch (the whole suite passes, Helm 3.18.4):

==> v-a2. a MeshConfig created between the render and the seed hook is not deleted (#1471)
  ✓ the upgrade failed on 'already exists' and left the MeshConfig alone; run again, it succeeded
  ✓ the MeshConfig created between the render and the seed hook is the same object (uid 02f4bc30-…), with its spec
  ✓ every workload is Ready (after the seed race)

bazel test //charts/... //e2e/...: 240 pass. The lint build and make format-check pass.

Not fixed, and not verified

  • The revision that creates the namespace the MeshConfig goes into (the exception above). Measured on kind with edge.enabled=true at defaults: revision 1's manifest holds the edge's MeshConfig and helm rollback aether 1 fails as before. The runbook says how to check a revision, how to get round it, and how to avoid it (edge.namespaceCreate=false with a namespace you made).
  • Under Helm 4's server-side apply the seed is not create-only (review round 3, reproduced). never stops every deletion, but the hook is an apply there, so in the race the seed is merged into the object created in the window: chart labels, hook annotations, and any meshConfig.proxy field the object does not set. With the default, empty meshConfig.proxy the spec does not change; with Helm 3 the object is untouched. Closing it needs a seed that is created and never applied, such as a hook Job running a create with its own ServiceAccount, RBAC and image. That is a new workload in the chart and is left as a decision for the owner; the comments, values.yaml, docs/configuration.md and the runbook now say what happens. The e2e leg runs under Helm 3 and cannot see this case.
  • Helm 4.2.0 was used for the delete-policy table only. The rollback measurements of the first round and the e2e suite are Helm 3.18.4; e2e/first-install.sh does not run under Helm 4 as it is (it calls helm list -a, a flag Helm 4 no longer has), which is older than this pull request and not changed here.
  • never is not a documented value of helm.sh/hook-delete-policy. That Helm ignores it is read in the source of 3.18.4 and 4.2.0 and measured with both; no other Helm version was tried.
  • The wait failure of row d+e was produced with an identity that may not list MeshConfigs. A timeout or an API error during the wait takes the same code path (read, not measured).
  • How Argo CD or another tool that maps Helm hook annotations to its own treats the unknown value was not tried.
  • A GitOps tool that renders with helm template and applies the result has no cluster to look the MeshConfig up in. It rendered the seed on every sync before, and still does, now with the hook annotation on it. How such a tool treats that annotation was not tried; the docs say to set meshConfig.createDefault=false there.
  • The nightly first-install job has not run with this leg; it was run locally only.

Chart version

aether → 2.4.24. main is at 2.4.22 (merged into this branch); open pull request #1495 takes 2.4.23, so a one-line Chart.yaml conflict is expected if it merges first.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

… a release's first revision works (#1471)

The chart seeds the default MeshConfig once and never renders it again. As a
release object it was in the first revision's manifest only, and still live:
helm rollback to that revision failed with 'no MeshConfig with the name
"default" found', because Helm patches a live object of the target manifest
from the current manifest's copy and there is none.

The seed is now a pre-install,pre-upgrade hook, in no revision's manifest. It
stays a release object on the one revision that also creates the namespace it
goes into (a pre-install hook runs before that namespace exists).

Template tests seen red first; e2e/first-install.sh gains a rollback leg.
Chart aether 2.4.21 -> 2.4.24.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo bpalermo added bug Something isn't working chart Helm charts labels Oct 9, 2026
Copilot AI balanced review requested due to automatic review settings October 9, 2026 11:58

Copilot AI 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.

🟡 Changes recommended

The operator documentation incorrectly limits legacy failures to revision 1 and misstates retained objects’ ownership annotations.

4 open findings
What changed in this PR

Moves seeded MeshConfig resources to Helm hooks so first-revision rollbacks succeed without replacing operator-managed configuration.

Changes:

  • Adds conditional pre-install,pre-upgrade hooks.
  • Adds template and end-to-end rollback coverage.
  • Updates chart version and operator documentation.
File Description
charts/​aether/​templates/​_helpers.tpl Determines hook versus release-object seeding.
charts/​aether/​templates/​controller-meshconfig.yaml Hooks the control-plane seed.
charts/​aether/​templates/​edge-meshconfig.yaml Hooks the edge seed where possible.
charts/​aether/​BUILD.bazel Adds Helm template tests.
charts/​aether/​Chart.yaml Bumps chart to 2.4.24.
charts/​aether/​values.yaml Documents seeding behavior.
e2e/​first-install.sh Tests rollback and reseeding.
docs/​configuration.md Updates configuration reference.
docs/​proposals/​015_mesh-config.md Records the design change.
docs/​runbook.md Adds upgrade and rollback guidance.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread charts/aether/BUILD.bazel Resolved
Comment thread charts/aether/templates/_helpers.tpl Resolved
Comment thread docs/proposals/015_mesh-config.md Resolved
Comment thread docs/runbook.md Resolved

Copilot AI 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.

🟡 Changes recommended

The default hook deletion policy can race with external recreation and replace operator-owned MeshConfig resources.

2 open findings
4 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 12:18

Copilot AI 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.

🟢 Approval recommended

The hook lifecycle, namespace exception, rollback behavior, documentation, and tests are consistent and comprehensive.

2 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 12:40

Copilot AI 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.

🟢 Approval recommended

The hook lifecycle, namespace exception, rollback behavior, tests, and documentation are consistent and complete.

2 open findings

🧠 Review effort: Balanced

bpalermo and others added 3 commits October 9, 2026 11:06
…between the render and the hook is left alone (#1471)

A hook with no helm.sh/hook-delete-policy gets before-hook-creation: Helm
deletes the live object of that name before creating the hook's. The lookup
that decides to render the seed and the hook are not atomic, so a MeshConfig
created in between was deleted and replaced by the seed, with the upgrade
reporting success (measured on kind, Helm 3.18.4 and 4.2.0).

The hook now carries helm.sh/hook-delete-policy: never, a value Helm does not
act on. hook-failed was measured too and rejected: under Helm 4's server-side
apply it deletes the operator's object when the wait after the apply fails.
With never the upgrade fails on "already exists" (or goes through with the
object in place) and succeeds when run again.

e2e/first-install.sh gets leg v-a2, which holds an upgrade between the render
and the seed hook with a slow pre-upgrade hook and creates a MeshConfig there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
# Conflicts:
#	charts/aether/Chart.yaml
#	docs/runbook.md
Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:39

Copilot AI 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.

🟡 Changes recommended

Helm 4 server-side apply can merge non-conflicting seed fields into an operator-created MeshConfig.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

…d to a MeshConfig created during the upgrade, not skipped (#1471)

The delete policy stops every deletion, but it does not make the seed
create-only: measured with Helm 4.2.0, a seed with tracingEnabled=true over an
object created in the window that set only accessLogsEnabled left both set.
The helper comment, the test comment, values.yaml, docs/configuration.md and
the runbook said the object was left alone; they now say what is merged in and
when the spec can change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:52

Copilot AI 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.

🟡 Changes recommended

The unresolved Helm 4 server-side-apply race can still merge seed fields into an operator-owned MeshConfig.

1 open finding

🧠 Review effort: Balanced

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

Labels

bug Something isn't working chart Helm charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chart: helm rollback to a release's first revision fails with 'no MeshConfig with the name "default" found'

2 participants