vibe-schedulerDocumentation

Reboot-safe, hardened hosted deployment (#272)

A hosted deployment runs three system units on one authority host:

  • the submission gateway (vq remote API on a Unix socket);

  • one scheduler driver per lane, which submits a principal’s jobs over the lane’s pinned SSH profile and runs the broker passes;

  • the hosted console, the MFA dashboard behind the reverse proxy.

Kernel updates and configuration changes need occasional reboots. This page covers what must hold for the services to come back unattended, and how to sandbox them. Templates: contrib/vq-gateway.service, contrib/vq-scheduler-driver.service, contrib/vq-hosted-console.service, contrib/vq-hosted-hardening.conf (a drop-in for existing units) and contrib/vq-planned-reboot with its service and timer. All paths in them are synthetic.

What survives a reboot

State

Across a reboot

Gateway keys, uploads, job index, results, observations

On disk under the gateway state directory. Kept.

Broker records and placements

On disk. Placed jobs are observed again from their target; an interrupted transfer is fenced and replayed under its idempotency key.

Scheduler jobs on PBS/Slurm

Keep running on the cluster. The driver re-attaches after boot.

Local jobs of a daemon on this host

Lost, unless the daemon was prepared with vq host prepare-reboot --apply. Then each is resubmitted once after boot (#249).

Client uploads in progress

Lost. The client retries; --idempotency-key keeps it from creating a second job.

Console sessions

Kept, in the authentication store under the console’s config directory.

Unix sockets under /run

Recreated by RuntimeDirectory= on start.

Boot order and start-up

  • Enable all three units for multi-user.target, ordered After=network-online.target. The lane SSH and the console’s mail relay need the network; the sockets do not.

  • The reverse proxy may start first. It answers 502/503 for the few seconds before a socket appears.

  • Lingering (loginctl enable-linger USER) starts the service user’s own user units at boot, for example a plain vq-daemon on the same host.

  • ExecStartPost fixes the socket’s group or mode. It must wait long enough: a warm restart creates the socket in about a second, but a cold boot imports everything from disk. The templates wait up to 30 s; a 2 s wait fails the start on a slow boot.

  • Restart=on-failure with StartLimitIntervalSec=600, StartLimitBurst=10 rides out a slow network or a lane that is briefly unreachable at boot.

  • Nothing may depend on an interactive secret. Lane keys are files with IdentityAgent none. Fleet SSH keys must be passphrase-free files, or held by a service-owned agent that starts at boot. Never point a hosted unit at an operator’s agent.

Upgrades

A hosted release is a directory with its own environment. Pin it with a drop-in (ExecStart= reset, then the new line) rather than by editing the unit. Move these together:

  • the gateway and driver ExecStart;

  • the driver’s local remote_vq wrapper (VQ_CONFIG_DIR/vq), which capacity samples run through; an older wrapper rejects newer config fields and every lane reports no capacity;

  • the console, when its config gains fields that older builds reject.

Back up each config and drop-in before switching, keep the previous release directory, and restart in the order driver, gateway, console.

Hardening

contrib/vq-hosted-hardening.conf sandboxes a unit without changing what it can reach:

  • ProtectSystem=strict and ProtectHome=read-only make the whole file system read-only. Each unit then lists its own writable state:

    Unit

    ReadWritePaths

    gateway

    ~/.local/share/vq (gateway and broker state), the lane state directory, ~/.ssh/sockets

    driver

    the same, plus the lane’s scratch directory

    console

    ~/.local/share/vq, the console’s config directory (authentication store), ~/.ssh/sockets

    ~/.ssh/sockets matters only where the fleet SSH config multiplexes (ControlPath).

  • No capabilities; private /tmp and /dev; kernel tunables, modules, logs, clock, hostname and control groups protected; ProtectProc=invisible; namespaces, realtime scheduling and SUID/SGID files refused.

  • SystemCallFilter=@system-service on the native architecture. RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK: netlink is needed by glibc’s getaddrinfo address check.

  • UnsetEnvironment=SSH_AUTH_SOCK keeps an inherited agent out of the process.

Left out on purpose:

  • MemoryDenyWriteExecute: libffi closures in Python extensions need it off.

  • ProcSubset=pid: host memory and load samples read /proc/meminfo and /proc/loadavg.

  • RemoveIPC: it would remove IPC objects of the account’s other sessions.

  • PrivateUsers: SSH and the lane UID check need the real account.

After installing it, run systemctl daemon-reload, restart one unit at a time and check it before the next:

systemd-analyze security vq-gateway.service     # exposure score
journalctl -u vq-gateway -b | grep -i -E 'read-only|permission denied|EROFS|EPERM'

A denied write shows up as Read-only file system or Permission denied. Add that path to the unit’s ReadWritePaths only if it is the unit’s own state.

A planned reboot by hand

  1. Prepare every vq daemon on the host. Scheduler jobs are reported as unaffected:

    ~/.config/vq-lane-g1/vq host prepare-reboot localhost --reason "kernel update"
    ~/.config/vq-lane-g1/vq host prepare-reboot localhost --reason "kernel update" --apply
    vq host prepare-reboot --reason "kernel update" --apply   # the account's own daemon, if any
    

    Reboot only when each verdict reads safe to reboot.

  2. Reboot.

  3. Check after boot:

    systemctl is-active vq-gateway vq-scheduler-driver vq-hosted-console
    curl -fsS --unix-socket /run/vq-gateway/api.sock http://localhost/v1/healthz
    curl -fsS https://console.example.org/health/live
    ~/.config/vq-lane-g1/vq host reboot-status localhost   # the daemon finished its plan
    journalctl -b -u vq-gateway -u vq-scheduler-driver -u vq-hosted-console -p warning
    

    From a client, vq remote info must show submission.available: true and the granted routes. A short job must reach a terminal phase.

Guarded weekly reboot

Unattended upgrades install kernels but should not reboot by themselves (Unattended-Upgrade::Automatic-Reboot "false", the default): a blind reboot can land in the middle of an update or a local job. vq-planned-reboot and its timer reboot inside a weekly window instead, and only when:

  • /run/reboot-required exists;

  • every daemon listed in /etc/vq-planned-reboot.conf reports safe to reboot after prepare-reboot --apply.

List each daemon with HOST localhost; a configured host name whose ssh is localhost is still reached over SSH and fails host-key checking. A lane driver’s own VQ_CONFIG_DIR/vq wrapper is a good executable: it carries the driver’s environment and release. A daemon whose vq predates prepare-reboot (#249) can never report safe to reboot, so the guard holds every reboot until that daemon is upgraded.

Otherwise it cancels the plans it made (vq host finish-reboot), logs why and exits non-zero, so the failure is visible in systemctl status and the next window tries again.

sudo install -m 0755 contrib/vq-planned-reboot /usr/local/sbin/
sudo install -m 0644 contrib/vq-planned-reboot.service contrib/vq-planned-reboot.timer /etc/systemd/system/
sudoedit /etc/vq-planned-reboot.conf      # USER VQ HOST ENV-FILE per daemon
sudo /usr/local/sbin/vq-planned-reboot --dry-run --force   # previews only
sudo systemctl daemon-reload && sudo systemctl enable --now vq-planned-reboot.timer
systemctl list-timers vq-planned-reboot.timer

Run by hand, the script never reboots unless --reboot-now is given; it exits 3 once every daemon is prepared. Only the systemd service reboots without the flag.

While another update tool runs, the timer stands down and exits 0. It only checks that tool’s lock (with lslocks) and its units, and never takes the lock, because a tool using flock -n would then refuse to start. The defaults are /run/full-update.lock and full-update*.service; set VQ_PLANNED_REBOOT_DEFER_LOCKS and VQ_PLANNED_REBOOT_DEFER_UNITS in a drop-in for another tool. Don’t schedule both at the same minute: a tool that starts in the same second may not hold its lock yet.

Another update tool that reboots the host itself can call vq-planned-reboot --prepare-only just before its reboot. It applies and checks every daemon the same way, but leaves the reboot to the caller. Exit status 0 means safe to reboot; otherwise the plans are already cancelled.