You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom API methods should support optional version + uid preconditions #1773
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.
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:
a new Preconditions message with the same two fields, added as an optional field on each custom-method request
reuse DeleteOptions under its current name, which reads oddly on a suspend
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.
Currently, #2957 proposes adding a uid guard to ResumeActor in the following form:
messageResumeActorRequest {
ObjectRefactor=1;
ExpectedSnapshotexpected=2; // actor_uid, snapshot_uuid, generation
}
// ExpectedSnapshot identifies the actor incarnation and checkpoint to resume.messageExpectedSnapshot {
// UID of the actor the caller observed.// +k8s:required// +k8s:format=k8s-uuidstringactor_uid=1;
// UUID of the checkpoint the caller observed.// +k8s:required// +k8s:format=k8s-short-namestringsnapshot_uuid=2;
// Generation of the checkpoint the caller observed.// +k8s:required// +k8s:minimum=1int32generation=3;
}
Activity
laoj2 commentedon Sep 21, 2026
Another example is
CreateTag.CreateTagRequestreferences the actor create the tag from via anObjectRef:substrate/pkg/proto/ateapipb/ateapi.proto
Lines 704 to 711 in bb0effe
So, if an atespace/actor-name is recreated, there's a risk we're tagging the wrong, new actor.
abhisheksharma2411 commentedon Oct 14, 2026
I'd like to take this, starting with
SuspendActoras your concrete example, but the API shape is a decision I don't want to make on my own.What's already there:
DeleteOptionshas exactly the fields this needs (optionalversionwith+k8s:minimum=1, optionaluidwith+k8s:format=k8s-uuid, both documented as "zero/empty skips the check"), and the server side already hasstore.Precondition,store.DeletePreconditionsandtoDeletePreconditionsincmd/ateapi/internal/controlapi/delete_options.go. So the machinery exists; it's the request shape that's missing.Three options I can see:
Preconditionsmessage with the same two fields, added as an optional field on each custom-method requestDeleteOptionsunder its current name, which reads oddly on a suspenduid/versiontoObjectRefitself, which would cover every custom method at once but changes a type used in a lot of placesI'd lean to 1, since it keeps
ObjectRefa pure reference and matches howDeleteOptionsis already carried as a separate optional field. Which would you prefer?One other thing I'm unsure about:
SuspendActorgoes throughactorWorkflow, 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.
haiyanmeng commentedon Nov 18, 2026
Currently, #2957 proposes adding a uid guard to
ResumeActorin the following form:I added
DO NOT MERGEto the PR for now.ateapi: rename store.DeletePreconditions to OptionalPrecondition (age…
ateapi: merge store.OptionalPrecondition into store.Precondition (age…