Skip to content

Commit eaf34c5

Browse files
check workerHostsActor before discarding worker in RevertActor
1 parent 02c938e commit eaf34c5

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

‎cmd/ateapi/internal/controlapi/workflow_revert.go‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,24 @@ func (w *ActorWorkflow) ensureWorkerDiscarded(ctx context.Context, actorRef reso
174174
ctx, done := stepSpan(ctx, "DiscardWorker")
175175
defer func() { err = done(err) }()
176176

177-
if actor.GetStatus().GetWorkerAssignment() != nil {
178-
if terr := w.ensureAteletTerminated(ctx, actorRef, actor, actorTemplate); terr != nil {
179-
// A terminate that comes back with a crash directive lands the
180-
// actor in CRASHED, which the user can revert again — that retry
181-
// needs no live worker.
182-
return maybeCrashActor(ctx, w.store, actorRef, terr, "while terminating the actor's workload", ateattr.OperationRevert)
183-
}
184-
if err := w.ensureVolumesDetached(ctx, actor, actorTemplate, "DetachVolumesForRevert", ateattr.OperationRevert); err != nil {
177+
if assignment := actor.GetStatus().GetWorkerAssignment(); assignment != nil {
178+
hosted, err := workerHostsActor(ctx, w.store, assignment.GetWorker().GetName(), actor.GetMetadata().GetUid())
179+
if err != nil {
185180
return err
186181
}
187-
if _, _, err := releaseWorker(ctx, w.store, actor); err != nil {
188-
return fmt.Errorf("while releasing worker: %w", err)
182+
if hosted {
183+
if terr := w.ensureAteletTerminated(ctx, actorRef, actor, actorTemplate); terr != nil {
184+
// A terminate that comes back with a crash directive lands the
185+
// actor in CRASHED, which the user can revert again — that retry
186+
// needs no live worker.
187+
return maybeCrashActor(ctx, w.store, actorRef, terr, "while terminating the actor's workload", ateattr.OperationRevert)
188+
}
189+
if err := w.ensureVolumesDetached(ctx, actor, actorTemplate, "DetachVolumesForRevert", ateattr.OperationRevert); err != nil {
190+
return err
191+
}
192+
if _, _, err := releaseWorker(ctx, w.store, actor); err != nil {
193+
return fmt.Errorf("while releasing worker: %w", err)
194+
}
189195
}
190196
}
191197

@@ -214,7 +220,7 @@ func (w *ActorWorkflow) ensureInProgressSnapshotDiscarded(ctx context.Context, a
214220
}
215221
// A suspend records the in-progress URI under the actor's own prefix
216222
// before atelet writes the first object, so a URI owned by anything else
217-
// is a corrupted record: deleting it would collect another actor's data.
223+
// is a corrupted record.
218224
owner := actorSnapshotOwner(actor)
219225
if !uri.OwnedBy(owner) {
220226
return fmt.Errorf("the in-progress snapshot %q is not owned by actor %s", inProgress, owner)

0 commit comments

Comments
 (0)