Repository navigation
Description
Problem
When a paused actor pinned to a node (status.assigned_node != "") fails placement on that node with ErrNoCapacity, ResumeActor calls detachFromFullNode in cmd/ateapi/internal/controlapi/workflow_resume_detach.go.
Before calling atelet.DetachActor to upload and delete the node-local checkpoint, detachFromFullNode checks whether any worker in the cluster has room for the actor once unpinned:
constraints := schedulingConstraints(actor, actorTemplate)
constraints.RequiredNodes = nil
constraints.MinFidelity = ateapi.SnapshotFidelity_SNAPSHOT_FIDELITY_ROOTFS
if _, err := w.scheduler.Schedule(ctx, constraints); err != nil {detachFromFullNode cannot claim a worker before DetachActor finishes uploading the snapshot, so it discards the worker Schedule returns (_) and only checks err != nil. Running a full Schedule for that boolean check does unnecessary work:
-
Scans the entire fleet even after finding a match: On a cluster where
assigned_nodeis full and other nodes have room,Schedulestill evaluates static filters, runtime matching, overhead booking, and capacity checks across all$N$ workers inworkercache. -
Allocates
candidatesand samples a winner that is thrown away:Scheduleappends every eligible worker in the highest tier intocandidatesand runs Power-of-Two-Choices, only fordetachFromFullNodeto discard the picked worker and callScheduleagain afterDetachActorcompletes.
Proposal
Replace the discarded Schedule call in detachFromFullNode with a short-circuit capacity check on Scheduler (such as HasRoomFor(ctx, constraints) or CanSchedule(ctx, constraints)):
- Stop at the first eligible worker with room: Walk the worker cache with the relaxed constraints (
RequiredNodes = nil,MinFidelity = ROOTFS), run the same static, runtime, and capacity checks asSchedule, and returntrueas soon as the first qualifying worker with room is found. - Skip candidate collection and sampling: Because no worker is being claimed yet, no
candidatesslice is allocated and Power-of-Two-Choices is skipped. Onceatelet.DetachActorcompletes and clearsassigned_node,ensureWorkerAssignedrunsScheduleto pick and bind the worker.
When other nodes in the cluster have free capacity, the pre-detach check stops after inspecting one or two workers instead of scanning all
Activity