fix(opencode): remove an exited container at launch #87
No reviewers
Labels
No labels
bug
cannot reproduce
duplicate
enhancement
help wanted
invalid
need info
need triage
need verification
not a bug
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
claudiomaradonna/azkaban!87
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/opencode-exited-container"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
An OpenCode launch names its container after the workspace, so that one
container at a time serves a workspace's state. A session that ends
badly can leave that container behind, exited, despite
--rm. Thelaunch then refused every later run on the workspace with
container '...' already serves this workspaceuntil someone removedthe container by hand, a step an unattended supervisor cannot take: it
retried in a loop.
Closes #86
What changed
On Linux, a launch that finds its workspace's container asks Podman for
its state. A container that is
exitedorstoppedis removed with anunforced
podman rm, the launch says so on standard error withopencode: removed exited container '<name>', and it runs. Before, itstopped with exit 1.
Any other state still stops the launch with the same message as before:
a
createdcontainer may be another launch about to start, and apausedone is a live session.When the removal fails, the launch stops before the run, lets the
engine's error through, and prints
container '<name>' has exited and could not be removed: remove it with 'podman rm <name>'.macOS is unchanged: the launch stops while the name exists. Apple
container reports only running and stopped containers, so an exited
container cannot be told from one about to start.
The check lives in
_azk_refuse_second_container(bin/azkaban), andthe state query in
azk_host_container_exited(lib/azk-host.sh).How to verify
The tests run against the vendored Podman stub, from a fresh checkout
with no setup. Base is
b6c8dc8, branch isf59aef7.On the branch:
On the base's code with the branch's tests:
Both tests fail: the first with exit 1 and
already serves this workspace, the second for lack of the removalerror. The pin of the kept refusal passes on both revisions:
All three were run with these results.
Untested: the scenario on a real host, since the machine that built
this has no Podman. On Linux with rootless Podman, with the workspace's
container left
Exited:Expected on the branch: the
removed exited containerline, a reply,and
exit=0; on the base,already serves this workspaceandexit=1. A second launch while one runs is expected to stop as before.make lint && .agents/hooks/shellcheck.sh repo && make testpassed onthe branch: 343 tests, 0 failures.
Considerations
podman container inspect --format '{{.State.Status}}'and of an unforced
podman rmrest on the stub until the hostscenario above is run.
--rmleaves the container when a supervisor stops the sessionis still unknown, so supervisors will keep leaving exited containers,
which the next launch now removes.
--rmremoves at the instant thelaunch removes it makes the removal fail; rerunning is enough.
pausedcontainerits
podman rmcommand probably needs--force; this was notchecked.
docs/macos.md,because the rule already has its home in
docs/configuration.md.