Skip to content

ateapi: short-circuit the pre-detach capacity check in detachFromFullNode #3810

Open

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:

  1. Scans the entire fleet even after finding a match: On a cluster where assigned_node is full and other nodes have room, Schedule still evaluates static filters, runtime matching, overhead booking, and capacity checks across all $N$ workers in workercache.
  2. Allocates candidates and samples a winner that is thrown away: Schedule appends every eligible worker in the highest tier into candidates and runs Power-of-Two-Choices, only for detachFromFullNode to discard the picked worker and call Schedule again after DetachActor completes.

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)):

  1. 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 as Schedule, and return true as soon as the first qualifying worker with room is found.
  2. Skip candidate collection and sampling: Because no worker is being claimed yet, no candidates slice is allocated and Power-of-Two-Choices is skipped. Once atelet.DetachActor completes and clears assigned_node, ensureWorkerAssigned runs Schedule to 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 $N$ workers in the fleet.

Metadata

Metadata

Labels

area/lifecyclearea/schedulingkind/cleanup

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions