Skip to content

Stop apply --enable-state deleting resources whose metadata changed - #148

Merged
99-not-out merged 1 commit into
mainfrom
fix/state-identity
Oct 7, 2026
Merged

99-not-out merged 1 commit into
mainfrom
fix/state-identity

Conversation

@99-not-out

@99-not-out 99-not-out commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: apply --enable-state no longer deletes a resource when its metadata changes.

What & why

With --enable-state, apply works out what to delete by matching each resource in the state against the files. It matched by all of a resource's metadata, so changing a Topic's metadata.description, or giving it a first label, made the applied topic look removed: apply deleted it and created it again — its messages are lost. Any metadata edit to a stateful resource can do this, and nothing in the output says the delete is a recreate (a dry run shows one delete and one update).

Changes

  • The state tells resources apart by kind, name and parents — the path and query parents its kind needs, a Gateway resource's vCluster, an interceptor's scope (Catalog.StateIdentity) — passed in where the state is loaded. Without it the old comparison is kept.
  • A resource applied again replaces its stored entry, so the state holds its current metadata.

Notes

The state matched a resource it had applied against the files by all of
its metadata. Changing a topic's description, or giving it a first
label, made the applied topic look removed: apply deleted it and created
it again, losing its data. The state now identifies a resource by its
kind, name and the parents its path or query needs (a Gateway resource's
vCluster, an interceptor's scope), and keeps the latest metadata of a
resource applied again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B464sFQc8q6VkehfkByBaX
@99-not-out
99-not-out merged commit 67d0575 into main Oct 7, 2026
7 checks passed
@99-not-out
99-not-out deleted the fix/state-identity branch October 7, 2026 09:19
99-not-out added a commit that referenced this pull request Oct 7, 2026
* fix(state): leave the state file untouched when nothing changed

Since #148 re-applying a managed resource replaces its entry with the
latest metadata, but it also bumped lastUpdated on every apply, so a run
that changed nothing still rewrote the state file. Only replace the entry,
and bump lastUpdated, when the stored entry actually differs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: never give the random interceptor fixture priority 0

Gateway rejects an interceptor priority below 1, and rand.IntN(100) drew 0
one run in a hundred.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants