Rack controllers update themselves to the region's version
The region offers its binary (version, arch, sha256) in each rack's state and serves it over mutual TLS; the rack stages it after checking checksum and version; a root path unit installs it, restarts the rack and rolls back if it does not register within a minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb245b1d51
commit
bbe45804c7
15 files changed
+364
-14
No files matched your search
@@ -50,10 +50,13 @@ for f in hosts hosts.dhcp; do [ -e "$DNS/$f" ] || install -m 0644 -o rollcall -g
|
||||
# until the region assigns a VLAN only loopback is served
|
||||
printf '# rollcall rack controller: the configuration is generated from the region'"'"'s network model\nbind-dynamic\ninterface=lo\nconf-dir=%s/conf.d/,*.conf\n' "$DNS" > /etc/dnsmasq.d/rollcall.conf
|
||||
install -m 0755 rollcall-dnsmasq-reload.sh /usr/local/bin/rollcall-dnsmasq-reload.sh
|
||||
install -m 0644 rollcall-dnsmasq.path rollcall-dnsmasq.service rollcall-rack.service /etc/systemd/system/
|
||||
install -m 0755 rollcall-rack-update.sh /usr/local/bin/rollcall-rack-update.sh
|
||||
install -d -m 0755 -o rollcall -g rollcall /var/lib/rollcall/update
|
||||
install -m 0644 rollcall-dnsmasq.path rollcall-dnsmasq.service rollcall-rack.service rollcall-rack-update.path rollcall-rack-update.service /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable dnsmasq.service rollcall-dnsmasq.path >/dev/null 2>&1
|
||||
systemctl enable dnsmasq.service rollcall-dnsmasq.path rollcall-rack-update.path >/dev/null 2>&1
|
||||
systemctl start rollcall-rack-update.path
|
||||
systemctl restart dnsmasq.service || { journalctl -u dnsmasq -n 5 --no-pager >&2; exit 1; }
|
||||
systemctl start rollcall-dnsmasq.path
|
||||
systemctl enable --now rollcall-rack.service
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=rollcall: install a rollcall binary the rack controller staged
|
||||
|
||||
[Path]
|
||||
PathExists=/var/lib/rollcall/update/ready
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
Description=rollcall: install the staged rollcall binary, restart the rack controller, roll back on failure
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/rollcall-rack-update.sh
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Installs a rollcall binary the rack controller staged (rollcall-rack-update.path).
|
||||
# The rack checked the region's checksum and the binary's version; this checks
|
||||
# them again, keeps the running binary as .prev, restarts the rack and puts the
|
||||
# previous binary back if the rack does not register with the region in 60 s.
|
||||
set -u
|
||||
D=/var/lib/rollcall/update
|
||||
BIN=/usr/local/bin/rollcall
|
||||
[ -f "$D/ready" ] || exit 0
|
||||
want=$(cat "$D/ready"); rm -f "$D/ready"
|
||||
cd "$D" || exit 1
|
||||
result() { echo "$(date -Is) $*" > "$D/last-result"; echo "$*"; }
|
||||
sha256sum -c rollcall.new.sha256 >/dev/null 2>&1 || { result "$want: checksum mismatch, not installed"; exit 1; }
|
||||
got=$(./rollcall.new version 2>/dev/null | awk '{print $2}')
|
||||
[ "$got" = "$want" ] || { result "$want: binary reports '$got', not installed"; exit 1; }
|
||||
cur=$("$BIN" version 2>/dev/null | awk '{print $2}')
|
||||
cp -p "$BIN" "$BIN.prev"
|
||||
install -m 0755 rollcall.new "$BIN.tmp" && mv -f "$BIN.tmp" "$BIN"
|
||||
since=$(date +%s)
|
||||
systemctl restart rollcall-rack.service
|
||||
for _ in $(seq 1 30); do
|
||||
sleep 2
|
||||
if journalctl -u rollcall-rack.service --since "@$since" -o cat 2>/dev/null | grep -q "^.*registered with"; then
|
||||
rm -f rollcall.new rollcall.new.sha256
|
||||
result "updated $cur -> $want"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
cp -p "$BIN.prev" "$BIN.tmp" && mv -f "$BIN.tmp" "$BIN"
|
||||
systemctl restart rollcall-rack.service
|
||||
result "$want did not register within 60s; rolled back to $cur"
|
||||
exit 1
|
||||
Reference in new issue
Block a user