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
馃 fix: an archive whose config write fails after a hook deleted the remote box leaves the workspace active聽#7465
Follow-up from the Codex review of #7100 (thread: #7100 (comment), src/node/services/daytona/daytonaLifecycleHooks.ts:25).
Problem
WorkspaceService.archive() runs the before-archive hooks first and persists archivedAt after them. Two hooks do something that cannot be undone there: Coder's archive hook deletes the Coder workspace when the archive setting is "delete", and #7100's Daytona hook deletes the sandbox of the workspace that created it. If the config write after the hooks fails (for example, the config file is not writable), the archive returns an error, but the remote box is already gone and the workspace stays active. Its next turn then reports that the box no longer exists.
For Daytona the state is recoverable: a second archive or a removal runs the hook again, the hook treats a sandbox that is already gone as deleted (test archives a workspace whose sandbox is already gone), and the archive then persists. But the first error does not say that the box was deleted.
Proposed fix
Choose one of these:
Persist an "archiving" marker before the hooks and finish the archive on the next start when the marker is present.
When the config write fails after an irreversible hook succeeded, say in the error that the remote box was deleted and that archiving again finishes the archive.
Moving the deletion to an after-archive hook is not a good fix: after-archive hooks never block the archive, so a failed delete would leave a billed box that no workspace record names.
Why it is deferred
The ordering is in WorkspaceService.archive() and Coder's delete-on-archive hook has it on main; #7100's Daytona hook follows the same contract. It needs a failed config write right after a successful delete.
Activity