clavarium 0.2.249-beta.1 → 0.2.250-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -963,11 +963,9 @@ case "$AREA $VERB" in
963
963
  [ $# -le 1 ] || usage
964
964
  if [ $# -eq 1 ]; then
965
965
  [ "$1" = "hard" ] || refuse "vm revive [hard]"
966
- if [ "$SAY" = "yes" ]; then echo "snap stop multipass.multipassd; pkill -KILL -x multipassd; snap start multipass.multipassd"; exit 0; fi
967
- timeout 120 snap stop multipass.multipassd || true
968
- pkill -KILL -x multipassd 2>/dev/null || true
969
- sleep 2
970
- run timeout 120 snap start multipass.multipassd
966
+ unstick="$CODE/current/app/deploy/multipass-unstick.sh"
967
+ if [ "$SAY" = "yes" ]; then echo "$unstick (daemon stopped, its old dnsmasq ended, failed starts reset, started)"; exit 0; fi
968
+ run timeout 300 bash "$unstick"
971
969
  else
972
970
  run timeout 170 snap restart multipass.multipassd
973
971
  fi ;;
@@ -1,3 +1,4 @@
1
+ import { fileURLToPath } from 'node:url';
1
2
  /* MULTIPASS UPDATED IN CLAVARIUM'S OWN WINDOW (23-11, its owner's ask, after a morning on a real server: snap
2
3
  * updated Multipass by itself at 06:08, every machine was left suspended, nothing could be reached).
3
4
  *
@@ -16,6 +17,8 @@ const BACK_TRIES = 36;
16
17
  const BACK_EVERY_MS = 5_000;
17
18
  export const TRY_EVERY_MS = 20 * 3600_000;
18
19
  /* In the data folder while it runs: the server's watch leaves Multipass alone (vmwatch.mjs, `paused`). */
20
+ /* Its daemon stopped, its old dnsmasq ended, systemd's failed starts reset, started (multipass-unstick.sh, 25-11). */
21
+ export const UNSTICK = fileURLToPath(new URL('multipass-unstick.sh', import.meta.url));
19
22
  export const MULTIPASS_UPDATING = 'multipass-updating';
20
23
 
21
24
  const first = (r) => String(r?.stderr || r?.stdout || '').trim().split('\n').filter(Boolean).pop()?.slice(0, 200) || `exit ${r?.code}`;
@@ -68,7 +71,7 @@ export async function multipassTurn({ run, mode, inWindow, busy, state, save, lo
68
71
  for (const [what, argv] of steps) {
69
72
  log(`multipass: it does not answer: ${what}`);
70
73
  if (argv) await sh(argv, REFRESH_MS);
71
- else { await sh(['snap', 'stop', 'multipass.multipassd'], SNAP_MS); await sh(['pkill', '-KILL', '-x', 'multipassd'], 30_000); await sleep(2_000); await sh(['snap', 'start', 'multipass.multipassd'], SNAP_MS); }
74
+ else await sh(['bash', UNSTICK], 300_000);
72
75
  if (await answers()) { log(`multipass: it answers again (${what})`); return true; }
73
76
  }
74
77
  return false;
@@ -0,0 +1,53 @@
1
+ #!/bin/bash
2
+ # MULTIPASS STOPPED AND STARTED FOR SURE (25-11, on a real server: after its update its daemon restarted, but its
3
+ # old dnsmasq -- the small server giving its machines their addresses -- stayed alive, still holding port 53; each new
4
+ # daemon died starting its own ("Address already in use"), systemd gave up ("Start request repeated too quickly"),
5
+ # and only a restart of the whole server freed it). Its daemon stopped; what stays of its dnsmasq in its control
6
+ # group ended; systemd's count of failed starts reset; started.
7
+ # Its machines left running by a daemon that died (qemu in its group, 25-11 on test-c: the new daemon cannot take
8
+ # them back -- "Failed to get shared write lock" on their disks -- and stays mute) are stopped too, step by step as
9
+ # a forced stop is (the host program's vm halt): asked to shut down from inside (with the VM manager's own key, a
10
+ # minute), then asked to end (10 s), then ended. Each step said; the server's watch then starts again those that ran.
11
+ # Run as root, by the host program (vm revive hard) and the updater (deploy/multipass-refresh.mjs).
12
+ set -u
13
+ UNIT=snap.multipass.multipassd.service
14
+ # Where the VM manager keeps its data (moved to another disk: its MULTIPASS_STORAGE), for its leases and its key.
15
+ DATA="/var/snap/multipass/common/data/multipassd"
16
+ MOVED_TO="$(sed -n 's/^Environment=MULTIPASS_STORAGE=\(\/[A-Za-z0-9/._-]*\)$/\1/p' /etc/systemd/system/$UNIT.d/override.conf 2>/dev/null | head -1)"
17
+ [ -n "$MOVED_TO" ] && [ -d "$MOVED_TO/data" ] && DATA="$MOVED_TO/data"
18
+ gone() { ! kill -0 "$1" 2>/dev/null; }
19
+ # A machine whose daemon died: shut down from inside, then asked to end, then ended.
20
+ halt_orphan() {
21
+ local pid="$1" name="$2" ip i
22
+ ip="$(awk -v n="$name" '$4 == n {print $3}' "$DATA/network/dnsmasq.leases" 2>/dev/null | tail -1)"
23
+ if [ -n "$ip" ] && [ -r "$DATA/ssh-keys/id_rsa" ] && timeout 20 ssh -i "$DATA/ssh-keys/id_rsa" -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 "ubuntu@$ip" sudo shutdown -h now >/dev/null 2>&1; then
24
+ # Its system shuts down (about 20 s on a test machine); its qemu then waits, paused (Multipass starts it
25
+ # with -no-shutdown): ended once its system is down.
26
+ for i in $(seq 1 45); do gone "$pid" && break; ping -c 1 -W 1 "$ip" >/dev/null 2>&1 || { [ "$i" -ge 5 ] && break; }; sleep 1; done
27
+ gone "$pid" || sleep 8 # its network goes before its disks are done
28
+ kill -TERM "$pid" 2>/dev/null || true
29
+ for i in $(seq 1 10); do gone "$pid" && break; sleep 1; done
30
+ gone "$pid" || kill -KILL "$pid" 2>/dev/null || true
31
+ echo " $name: shut down from inside"; return
32
+ fi
33
+ kill -TERM "$pid" 2>/dev/null || true
34
+ for i in $(seq 1 10); do gone "$pid" && { echo " $name: asked to end"; return; }; sleep 1; done
35
+ kill -KILL "$pid" 2>/dev/null || true
36
+ echo " $name: ended"
37
+ }
38
+ timeout 120 snap stop multipass.multipassd >/dev/null 2>&1 || true
39
+ for procs in "/sys/fs/cgroup/system.slice/$UNIT/cgroup.procs" "/sys/fs/cgroup/systemd/system.slice/$UNIT/cgroup.procs"; do
40
+ [ -r "$procs" ] || continue
41
+ for pid in $(cat "$procs" 2>/dev/null); do
42
+ comm="$(cat "/proc/$pid/comm" 2>/dev/null)"
43
+ case "$comm" in
44
+ dnsmasq) echo "its old dnsmasq ended ($pid)"; kill -KILL "$pid" 2>/dev/null || true ;;
45
+ qemu-system-*) name="$(tr '\0' ' ' < "/proc/$pid/cmdline" 2>/dev/null | grep -o 'instances/[a-z0-9-]*' | head -1 | cut -d/ -f2)"
46
+ echo "a machine left by the dead daemon, stopped: ${name:-?} ($pid)"; halt_orphan "$pid" "${name:-?}" ;;
47
+ esac
48
+ done
49
+ done
50
+ pkill -KILL -x multipassd 2>/dev/null || true
51
+ systemctl reset-failed "$UNIT" 2>/dev/null || true
52
+ sleep 2
53
+ timeout 120 snap start multipass.multipassd
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.249-beta.1",
3
+ "version": "0.2.250-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.249-beta.1",
9
+ "version": "0.2.250-beta.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.249-beta.1",
3
+ "version": "0.2.250-beta.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",