Skip to content

Custom API methods should support optional version + uid preconditions #1773

Description

Update APIs support optional version + uid preconditions to avoid mutating stale objects.

Custom API methods don't have the same protections.

One concrete example is SuspendActor.
Imagine you have 2 independent operators (controllers, reconciliation loops, manually calling kubectl, etc...) called O1 and O2.
t1 - O1 reads the state of ate-demo-counter/counter1
t2 - O2 deletes ate-demo-counter/counter and recreates another actor with the same name
t3 - O1 suspends ate-demo-counter/counter1

O1 has now suspended a completely different actor, potentially running on a different worker / node. This is unlikely the desired outcome. Instead the SuspendActor call from O1 should fail with VersionConflict or NotFound.

We should allow clients to provide optional version + uid preconditions for custom APIs to avoid mutating stale objects.

Activity

  1. added
    kind/feature
    on Sep 21, 2026
  2. laoj2 commented on Sep 21, 2026

    @laoj2
    Collaborator

    Another example is CreateTag. CreateTagRequest references the actor create the tag from via an ObjectRef:

    // source_actor is the suspended Actor whose external snapshot this tag
    // captures. The tag lives in this Actor's Atespace. Set once at creation and
    // immutable afterward.
    //
    // +k8s:required
    // +k8s:subfield(atespace)=+k8s:required
    // +k8s:immutable
    ObjectRef source_actor = 4;

    So, if an atespace/actor-name is recreated, there's a risk we're tagging the wrong, new actor.

  3. abhisheksharma2411 commented on Oct 14, 2026

    @abhisheksharma2411

    I'd like to take this, starting with SuspendActor as your concrete example, but the API shape is a decision I don't want to make on my own.

    What's already there: DeleteOptions has exactly the fields this needs (optional version with +k8s:minimum=1, optional uid with +k8s:format=k8s-uuid, both documented as "zero/empty skips the check"), and the server side already has store.Precondition, store.DeletePreconditions and toDeletePreconditions in cmd/ateapi/internal/controlapi/delete_options.go. So the machinery exists; it's the request shape that's missing.

    Three options I can see:

    1. a new Preconditions message with the same two fields, added as an optional field on each custom-method request
    2. reuse DeleteOptions under its current name, which reads oddly on a suspend
    3. add optional uid/version to ObjectRef itself, which would cover every custom method at once but changes a type used in a lot of places

    I'd lean to 1, since it keeps ObjectRef a pure reference and matches how DeleteOptions is already carried as a separate optional field. Which would you prefer?

    One other thing I'm unsure about: SuspendActor goes through actorWorkflow, not a direct store call like the deletes, so the precondition has to be threaded into the workflow. Worth checking that lands where you'd expect before I write it.

    Happy to hold until the API audit in #2433 settles if adding fields right now would collide with it.

  4. added
    prio/P0
    on Nov 17, 2026
  5. haiyanmeng commented on Nov 18, 2026

    @haiyanmeng
    Collaborator

    Currently, #2957 proposes adding a uid guard to ResumeActor in the following form:

    message ResumeActorRequest {
      ObjectRef actor = 1;
      ExpectedSnapshot expected = 2;  // actor_uid, snapshot_uuid, generation
    } 
    
    // ExpectedSnapshot identifies the actor incarnation and checkpoint to resume.
    message ExpectedSnapshot {
      // UID of the actor the caller observed.
      // +k8s:required
      // +k8s:format=k8s-uuid
      string actor_uid = 1;
    
      // UUID of the checkpoint the caller observed.
      // +k8s:required
      // +k8s:format=k8s-short-name
      string snapshot_uuid = 2;
    
      // Generation of the checkpoint the caller observed.
      // +k8s:required
      // +k8s:minimum=1
      int32 generation = 3;
    }

    I added DO NOT MERGE to the PR for now.

  6. self-assigned this
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/api-machineryarea/securitykind/featureprio/P0

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions