Repository navigation
Bring Workspace sessions back after an unclean shutdown too - #113
Open
tigerblue77 wants to merge 7 commits into
Open
tigerblue77 wants to merge 7 commits into
tigerblue77 wants to merge 7 commits into
Conversation
Kasm routes to a session by the address its container was created with, while Docker gives a starting container the lowest free address. Record the address of each running or paused session on shutdown and pin the container back to it on start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
dockerd restarts session containers through their unless-stopped policy, then svc-kasm stops every running container, so Kasm keeps listing sessions as running or paused while their containers are stopped. Start the sessions recorded on shutdown again, pausing those that were paused, before the services start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
svc-kasm/finish does not run when the container is killed, so nothing records the sessions. dockerd's own records still show which session containers were running or paused, and at which address, until dockerd starts again. Build the state file from them in init-config-kasm when finish has not written one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
…store Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
…527pj-unclean Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
With -exec ... {} +, jq gets every config.v2.json in a single run and
find exits non-zero when it fails. The block is the last command of
init-config-kasm, so a record truncated by a power loss would fail the
oneshot and every record after it would be dropped. Run jq once per
record instead: a bad one only loses itself and find still exits 0.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RmwHZxdRuWgp9chBZTZTMn
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
When
svc-kasm/finishhas not written/opt/kasm_sessions.state,init-config-kasmbuilds it from dockerd's container records (/opt/docker/containers/*/config.v2.json), before dockerd starts and rewrites them. It records the session containers (kasm.kasmid) whose record says they were running, marks the paused ones as paused, and notes their address on each network.svc-kasm/runthen restores them as after a clean stop.Benefits of this PR and context:
closes #111
Depends on #109, whose commits are included here until it is merged. Restoring after an unclean shutdown also needs dockerd to start, see #112.
How Has This Been Tested?
#109 plus this change on
1.19.0-ls150, thendocker kill kasmanddocker start kasm:Exited (2)while Kasm shows them as running;.10and reachable, B is paused at.11and reachable once resumed;1;finish.I also ran the extraction on records without labels, records without networks, a truncated record (skipped, the others are still extracted) and an empty containers directory.
Source / References: