Skip to content

atecontroller: reclaim golden actor on ActorTemplate delete - #879

Closed
Alex Bulankou (AlexBulankou) wants to merge 1 commit into
agent-substrate:mainfrom
AlexBulankou:a4s1/actortemplate-delete-finalizer
Closed

atecontroller: reclaim golden actor on ActorTemplate delete#879
Alex Bulankou (AlexBulankou) wants to merge 1 commit into
agent-substrate:mainfrom
AlexBulankou:a4s1/actortemplate-delete-finalizer

Conversation

@AlexBulankou

Copy link
Copy Markdown
Collaborator

The ActorTemplate controller declares the actortemplates/finalizers RBAC verb but installs no finalizer, so deleting an ActorTemplate lets the CR be GC'd immediately while the backing golden actor + snapshot blobs live on in the store — unreclaimable once status.GoldenActorID is gone with the CR.

This adds an ate.dev/golden-actor-cleanup finalizer:

  • Installed on first reconcile (before the golden actor is created), so a delete that races template setup still triggers reclamation.
  • On delete, cleanupGoldenActor runs while the finalizer is held, then releases it:
    • IdempotentNotFound (already reclaimed) or empty GoldenActorID (actor never created) → success.
    • SUSPENDED-precondition awareDeleteActor requires SUSPENDED/CRASHED; a template deleted mid-lifecycle may have a RUNNING golden actor (FailedPrecondition), so we SuspendActor + requeue (5s) rather than deadlock the CR's deletion.

Tests: mock extended with DeleteActor/SuspendActor; new cases for finalizer-install, delete-when-suspended, delete-when-running (suspend+requeue), delete-when-NotFound, delete-when-no-GoldenActorID. go build ./..., go vet, and the controller test suite pass locally.

The ActorTemplate controller declares the actortemplates/finalizers RBAC
verb but installs no finalizer, so deleting an ActorTemplate orphans its
golden actor and snapshot blobs once status.GoldenActorID is GCd with
the CR. Add an ate.dev/golden-actor-cleanup finalizer: installed on
first reconcile, and on delete the golden actor is suspended if still
running (FailedPrecondition -> SuspendActor + requeue) then deleted
idempotently (NotFound / empty GoldenActorID are success).

Signed-off-by: Alex Bulankou <alexbu@google.com>
@juli4n

Copy link
Copy Markdown
Collaborator

The ActorTemplate resource is being moved to substrate API so I don't see much value in fixing this.

@zoez7

Copy link
Copy Markdown
Collaborator

+1 I don't think we need to worry about this right now, because we decided to have ActorTemplate as a substrate resources so will remove the current CRD and controllers for it.

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.

3 participants