Skip to content

ateapi: check mounted volumes are attachable and test assigned_node detach on crash - #2611

Merged
Michelle Au (msau42) merged 6 commits into
agent-substrate:mainfrom
lekhoavu2909:volume-assigned-node-detach
Oct 20, 2026
Merged

Michelle Au (msau42) merged 6 commits into
agent-substrate:mainfrom
lekhoavu2909:volume-assigned-node-detach

Conversation

@lekhoavu2909

@lekhoavu2909 Vu Le (lekhoavu2909) commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Some storage backends (e.g. Cloud Filestore IP export rules) restrict a volume to the node it is published to via CSI ControllerPublishVolume / ControllerUnpublishVolume, so every publish must be matched by an unpublish to the same node. Since #2222 , detach targets ActorStatus.assigned_node, which survives crashes and worker loss. This PR adds checks before attach and test coverage for the paths where detach used to be skipped.
Follows #2094, which covers the publish side.

  • ateapi: check mounted volumes are attachable before publishing
  • test(ateapi): cover volume detach via assigned_node after crash or worker loss

Changes

  • Worker without a node name: assignWorkerAttempt rejects such a worker with when the actor mounts external volumes. Previously the resume failed in ensureVolumesAttached, after the worker was booked.

  • Volume checks before attach: ensureVolumesAttached checks that every mounted volume is STATUS_CREATED and has a storage_volume_id before any attach call, so one bad volume can't leave earlier volumes published.

  • Unit tests, functional tests

  • E2E: assigned_node equals the worker's node_name while RUNNING and is cleared after suspend and revert. The OSS NFS driver doesn't implement ControllerPublishVolume.

  • Tests pass

@lekhoavu2909
Vu Le (lekhoavu2909) marked this pull request as ready for review October 13, 2026 21:45
@lekhoavu2909 Vu Le (lekhoavu2909) self-assigned this Oct 13, 2026
ref := &ateapipb.ObjectRef{Atespace: actor.GetMetadata().GetAtespace(), Name: actor.GetMetadata().GetName()}
return getMountedActorVolumes(ctx, ref, actor.GetStatus().GetExternalVolumes(), tmpl)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: generally helper functions improve readability, but this is sort of a wrapper for another helper function. I'd recommend keeping it as it was

Comment on lines +679 to +688
func checkVolumesAttachable(volumes []*ateapipb.ExternalVolume) error {
for _, vol := range volumes {
switch {
case vol.GetStatus() != ateapipb.ExternalVolume_STATUS_CREATED:
return apierror.FailedPrecondition("volume %q is %s, want %s before it is attached", vol.GetName(), vol.GetStatus(), ateapipb.ExternalVolume_STATUS_CREATED)
case vol.GetStorageVolumeId() == "":
return apierror.FailedPrecondition("volume %q has no storage volume ID to attach", vol.GetName())
}
}
return nil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are actually getting rid of volume status in #2456. I don't think you need to rebase on the change, just use the StorageVolumeID != "" check.

@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the volume-assigned-node-detach branch from 58095e4 to 5567567 Compare October 14, 2026 18:00
@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the volume-assigned-node-detach branch 2 times, most recently from a88d3b4 to 47d2b5c Compare October 14, 2026 21:08
Comment on lines +530 to +532
if assignedWorker.GetNodeName() == "" && len(getMountedActorVolumes(ctx, ref, actor.GetStatus().GetExternalVolumes(), actorTemplate)) > 0 {
return nil, nil, apierror.FailedPrecondition("worker %s has no node name to attach the actor's volumes to", assignedWorker.GetMetadata().GetName())
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 should-fix 🟡 – Gating this check on mounted volumes still lets actors without volumes book a nodeless worker and fail right after in ensureVolumesAttached (cmd/ateapi/internal/controlapi/workflow_resume.go:732). Every actor needs a node name (Worker.node_name and WorkerAssignment.node_name are required, and ensureAteletRestored dials atelet by node). Returning here after workerHoldingStaleClaim also leaves a stale claim unreleased. Reject an empty node name in scheduling.Applies (or unconditionally here) instead of only when volumes are mounted, and drop the wantErr: false case in TestAssignWorkerAttempt_WorkerWithoutNodeRejectsVolumes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

Comment on lines +2619 to +2620
mockVolume("u", "id-u"),
mockVolume("o", "id-o"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit 🟢 – Seeding u and o with non-empty storage IDs means "all provisioned" would still pass if checkVolumesAttachable checked actor.GetStatus().GetExternalVolumes() instead of only mounted volumes. Give u and o empty storage IDs here so the test also verifies unmounted and undeclared volumes are ignored.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Comment on lines +380 to +382
if storageClass != "" {
requireAssignedToWorkerNode(ctx, t, clients, actorRef)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit 🟢 – assigned_node is set on every resume and cleared on every suspend and revert, whether the actor mounts an external volume or not. Drop the storageClass != "" guard here and on lines 428 and 470 so clusters without a CSI StorageClass still verify assigned_node.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@bowei Bowei Du (bowei) added area/api-machinery area/storage area/tests Enhancing / fixing test coverage. kind/bug Something isn't working / bugfixes labels Oct 19, 2026
@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the volume-assigned-node-detach branch 3 times, most recently from 6f25f23 to c1b3ec1 Compare October 19, 2026 20:29
@msau42
Michelle Au (msau42) added this pull request to the merge queue Oct 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 19, 2026
@msau42
Michelle Au (msau42) added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
@msau42

Copy link
Copy Markdown
Collaborator

Can you double check the failing tests?

@lekhoavu2909

Copy link
Copy Markdown
Collaborator Author

Can you double check the failing tests?

Just look into it, I think it's some ephemerall runner GitHub stall rather than a code issue

@msau42
Michelle Au (msau42) added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
@lekhoavu2909
Vu Le (lekhoavu2909) force-pushed the volume-assigned-node-detach branch from 55e5822 to 3102795 Compare October 20, 2026 04:40
@msau42
Michelle Au (msau42) added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
@lekhoavu2909

Copy link
Copy Markdown
Collaborator Author

PR#2961 fixed the e2e ingressauth test, I also updated the capacity volume to conform to PR#2769

…s assigned_node to be retained after synchronous suspend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api-machinery area/storage area/tests Enhancing / fixing test coverage. kind/bug Something isn't working / bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants