Skip to content

fix(finalizers): keep other controllers' finalizers - #53

Open
lexfrei wants to merge 1 commit into
masterfrom
fix/finalizer-patch
Open

lexfrei wants to merge 1 commit into
masterfrom
fix/finalizer-patch

Conversation

@lexfrei

@lexfrei lexfrei commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Adding and removing the robotlb finalizer no longer touches finalizers of other controllers.

Adding used a JSON merge patch that set metadata.finalizers to a one-element list, and a merge patch replaces a list as a whole. Removal wrote back the list read from the cache, so a finalizer added or removed in between was lost or came back. Both now use a strategic merge patch, where metadata.finalizers is merged by value. Adding appends robotlb's entry, and removal deletes it with $deleteFromPrimitiveList.

I checked both patches on a kind cluster, with another finalizer already on a Service. The new add left ["robotlb/finalizer","example.com/other"] and the removal left ["example.com/other"]. The old merge patch left only robotlb's. The tests pin the patch type, so going back to a merge patch fails them.

Closes #40

Adding the robotlb finalizer used a JSON merge patch that set
metadata.finalizers to a one-element list. A merge patch replaces a
list as a whole, so every finalizer another controller had put on the
Service was dropped. Removal wrote back the list read from the cache,
so a finalizer added or removed in between was lost or came back.

metadata.finalizers is merged by value in a strategic merge patch, so
adding now appends only robotlb's entry and removal deletes only that
entry with a deleteFromPrimitiveList directive.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
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.

Adding the robotlb finalizer removes every other finalizer on the Service

1 participant