Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ init_diagram: |
"kasm:latest" <- Base Images
# changelog
changelogs:
- {date: "23.09.26:", desc: "Also bring Workspace sessions back after an unclean shutdown."}
- {date: "23.09.26:", desc: "Bring running and paused Workspace sessions back after a container restart."}
- {date: "23.09.26:", desc: "Give Workspace sessions their address back after a container restart."}
- {date: "07.08.26:", desc: "Fix NVIDIA passthrough to Workspace containers by generating a CDI specification inside the DinD layer."}
- {date: "04.08.26:", desc: "Give kasm_manager a healthcheck start period so a cold start does not leave kasm_proxy created but never started."}
- {date: "16.04.26:", desc: "Update for 1.18.1 release. Use rolling service images. Bump docker to v29."}
Expand Down
6 changes: 6 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/init-config-kasm/run
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ if [[ ! -L "/var/lib/docker-plugins" ]]; then
mkdir -p /var/lib/docker-plugins/rclone/config
mkdir -p /var/lib/docker-plugins/rclone/cache
fi

# After an unclean shutdown svc-kasm/finish has not recorded the sessions, but
# dockerd's records, read before it starts, still hold them as they were
if [[ ! -f /opt/kasm_sessions.state && -d /opt/docker/containers ]]; then
find /opt/docker/containers -name config.v2.json -exec jq -r 'select(.Config.Labels["kasm.kasmid"] and .State.Running) | "\(.ID) \(if .State.Paused then "paused" else "running" end)\(.NetworkSettings.Networks | to_entries? // [] | map(" \(.key)=\(.value.IPAddress)") | join(""))"' {} \; > /opt/kasm_sessions.state
fi
4 changes: 4 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-kasm/finish
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

# Kasm routes to a session by the address its container was created with
# shellcheck disable=SC2016
docker ps -q --filter "label=kasm.kasmid" | xargs -r docker inspect --format '{{.Id}} {{.State.Status}}{{range $network, $settings := .NetworkSettings.Networks}} {{$network}}={{$settings.IPAddress}}{{end}}' > /opt/kasm_sessions.state

/opt/kasm/bin/stop
15 changes: 15 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-kasm/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ done
# Stop any running containers that shouldn't be
docker ps -q | xargs docker stop &> /dev/null

# Restore sessions before the services start, as Docker gives a starting
# container the lowest free address, not its previous one
if [[ -f /opt/kasm_sessions.state ]]; then
while read -r id status networks; do
for network in ${networks}; do
[[ -n "${network#*=}" ]] || continue
docker network disconnect --force "${network%%=*}" "${id}"
docker network connect --ip "${network#*=}" "${network%%=*}" "${id}" || docker network connect "${network%%=*}" "${id}"
done
docker start "${id}" > /dev/null
[[ "${status}" == "paused" ]] && docker pause "${id}" > /dev/null
done < /opt/kasm_sessions.state
rm -f /opt/kasm_sessions.state
fi

if [[ -f /opt/kasm/bin/start ]]; then
/opt/kasm/bin/start
fi
Loading