Repository navigation
fix(operator): key timed entity queue by uid to keep delete/recreate events apart - #1267
Merged
Merged
Conversation
…events apart TimedEntityQueue keyed pending entries by namespace/name and preserved a pending Deleted type on merge while taking over the incoming entity. When an object was deleted and recreated under the same name within the coalescing window, the new object's Added was merged into the old object's Deleted: DeletedAsync received the live object and the new object was never reconciled until a generation bump or re-list. Entries are now keyed by the object's UID (falling back to namespace/name for entities without a UID), so the old object's Deleted and the new object's Added are scheduled independently. Non-deleted entries whose name now resolves to a different (recreated) object are skipped on dequeue, as that object is reconciled through its own entry. Fixes #1266
|
🎉 This PR is included in version 13.3.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This was referenced Oct 9, 2026
This was referenced Oct 19, 2026
This was referenced Oct 26, 2026
This was referenced Nov 13, 2026
This was referenced Nov 19, 2026
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1266
Problem
TimedEntityQueue<TEntity>keyed pending entries bynamespace/name, and its merge logic preserved a pendingDeletedreconciliation type while taking over the incoming entity. When an object was deleted and a new object with the same name was created while theDeletedentry was still pending (one 100 ms promotion tick for watch events, the full backoff for a failedDeletedAsyncretry), the two different objects were coalesced:DeletedAsyncwas invoked with the new, still existing object.Addedreconciliation was lost. Because the watcher's UID-keyed generation cache had already recorded the new object's generation, it stayed unreconciled until a spec change or a watch re-list.The same happened in reverse when a
Deletederror-retry of the old object hit a pendingAddedof the new one.The name-based key dates back to #801, which added the namespace to the original name-only key (#800); the UID was never considered. All other identity-sensitive components of the pipeline (watcher dedup cache, shared pipeline membership, per-entity reconcile locks) are already UID-based.
Changes
TimedEntityQueueExtensions.GetKeynow returns the entity's UID and falls back tonamespace/nameonly for entities without a UID (e.g. locally constructed objects passed toEntityQueue<T>). TheDeleted-preserving merge rule is unchanged, but now only applies to events of the same object.EntityQueueBackgroundService.ReconcileSingleAsyncskips a non-deleted entry when the object loaded by name has a different UID than the queued entity. Without this, a stale entry of a deleted object (e.g. a pendingrequeueAfterwhoseDeletedevent was never observed because of a re-list) would reconcile the recreated object under the old UID's lock, i.e. potentially concurrently with the recreated object's own entry.queue-strategy.mdxdescribes the UID-based de-duplication contract;controllers.mdxnotes thatDeletedAsyncof a deleted object andReconcileAsyncof its recreated namesake are independent and may run in any order or in parallel.Behaviour change
No public API signature changes, but observable behaviour changes:
DeletedAsyncwith the old object andReconcileAsyncwith the new one. They are not ordered relative to each other.GetKeyreturns the UID for entities that have one. CustomITimedEntityQueue<T>implementations following the documented contract should de-duplicate by UID as well.Tests
TimedEntityQueue: the reproduction from the issue (pendingDeleted+Addedof the recreated object), the reverse case (Deletedretry + pendingAdded), merge of same-UID entries, and theGetKeyUID/fallback behaviour.EntityQueueBackgroundService: a stale entry is skipped when the object was recreated.ScopeAwareEntityQueueBackgroundServicetests used different UIDs only to label "snapshot" and "current" state of the same object; they now share the UID and differ by resource version.