Skip to content

fix: populate involvedObject name/namespace on Finalized events for already-deleted objects - #215

Open
OsoriAndOmori wants to merge 1 commit into
awslabs:mainfrom
OsoriAndOmori:fix/finalized-event-missing-object-name
Open

fix: populate involvedObject name/namespace on Finalized events for already-deleted objects#215
OsoriAndOmori wants to merge 1 commit into
awslabs:mainfrom
OsoriAndOmori:fix/finalized-event-missing-object-name

Conversation

@OsoriAndOmori

Copy link
Copy Markdown

What

cleanupNotFound records a "Finalized" event for each finalizer that
was removed while reconciling an object that has already been deleted.
The object passed to the event recorder is only obtained via
object.New[T]() and is never populated by Get() (which returned
NotFound), so the event's involvedObject.Name/Namespace were
always empty.

req.Name/req.Namespace are already known at this point, so this
sets them on o before it's used to record the event.

Why

Downstream log processors that key off involvedObject (e.g. Grafana
Alloy's loki.source.kubernetes_events) reject events with an empty
involved object name and log an error for every occurrence
(err="no involved object for event"). This fires on every
finalizer removal for an object that no longer exists — e.g. Karpenter
removing karpenter.sh/termination from a Node/NodeClaim as the last
finalizer, which happens on every node termination.

Testing

  • Added assertions to the existing "should emit termination metrics
    when deletion timestamp is set" tests (both Controller and
    GenericObjectController) verifying the Finalized event's
    involvedObject carries the correct Name/Namespace.
  • Verified the new assertions fail against the pre-fix code and pass
    with the fix.
  • go build ./..., go vet ./..., gofmt -l, go test ./... all
    clean.

@OsoriAndOmori
OsoriAndOmori requested a review from a team as a code owner August 10, 2026 02:56
@OsoriAndOmori
OsoriAndOmori force-pushed the fix/finalized-event-missing-object-name branch from 393abe9 to 38cc56e Compare August 10, 2026 02:58
…lready-deleted objects

cleanupNotFound records a "Finalized" event for each finalizer that was
removed, but the object passed in was only obtained via object.New[T]()
and was never populated by Get() (which returned NotFound). As a result
the event's involvedObject.Name was always empty, which downstream log
processors (e.g. Grafana Alloy's loki.source.kubernetes_events) reject
with "no involved object for event".

req.Name/req.Namespace are already known at this point, so set them on
o before it's used to record the event.
@OsoriAndOmori
OsoriAndOmori force-pushed the fix/finalized-event-missing-object-name branch from 38cc56e to cb25130 Compare August 10, 2026 02:59
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.

1 participant