Skip to content

Maintenance and Troubleshooting

The administrator’s daily routine: keeping the fleet clean, intervening on a host, rolling back after a bad configuration, reading logs.

All these commands target a host (or a pattern / list) via colmena:

CommandEffect
just enter <host>Open an SSH shell (alias e)
just reboot <host>Reboot
just halt <host>Shut down
just gc <host> [keep]Purge generations + clean the store
just fix-boot <host>Reinstall the boot loader

The keep argument of just gc limits the purge:

  • just gc <host>: keeps only the current generation.
  • just gc <host> 3: keeps the last 3 generations, including the current one.
  • just gc <host> 3d: removes generations older than 3 days.

Before committing or deploying, normalize the repository:

Fenêtre de terminal
just clean # fix + check + generate + format
  • just check: code + unit tests + flake checks (before deployment).

Each deployment creates a NixOS generation. In case of issues:

  1. At boot : choose a previous generation from the boot menu.

  2. Live rollback : revert to the previous generation then make it active:

    Fenêtre de terminal
    just enter <host>
    sudo nixos-rebuild switch --rollback
  3. Through code : git revert the faulty configuration, then redeploy:

    Fenêtre de terminal
    just apply <host>
Fenêtre de terminal
just enter <host>
journalctl -u <service> -n 100 --no-pager # logs d'un service
journalctl -p err -b # erreurs depuis le démarrage
systemctl status <service> # état d'une unité

Symptom: systemctl --failed lists, right after boot, units that start back up without a hitch once manually restarted (NFS mounts, OIDC provisioning, anything that resolves a name).

Cause: on a gateway, the system resolver is AdGuard Home (nameserver 127.0.0.1). Its unit is Type=simple, so systemd declares it active as soon as the process starts — about twenty seconds before it actually listens on port 53. Anything resolving a name during that window fails.

The framework puts up a barrier for this: dns-ready.service queries the local resolver until it gets a response, and blocks nss-lookup.target until then.

Fenêtre de terminal
systemctl status dns-ready # when names got resolved
journalctl -b -u adguardhome | head -30 # when the DNS proxy finally listens

A unit that resolves a name at boot must therefore order itself after this target — after = [ "nss-lookup.target" ] for a service, the mount option x-systemd.after=nss-lookup.target for a mount point. On non-gateway hosts, the target is reached immediately: no added delay.

A gateway does not request its own certificates: the HCS obtains them, and the sync-caddy-certs unit copies them every ten minutes from the HCS to the local Caddy storage.

Fenêtre de terminal
systemctl status sync-caddy-certs # dernier passage et son résultat
journalctl -u sync-caddy-certs -n 50
systemctl list-timers sync-caddy-certs

The transfer goes through two directories:

PathRole
/var/lib/caddy-cert-syncStaging area (StateDirectory of the unit)
/var/lib/caddy/storageActual Caddy storage being served

The unit runs as root, pulls from the HCS using the nix user’s SSH key, then publishes to the Caddy storage. It first waits for the tailnet to be actually mounted (up to five minutes), then retries the transfer three times before giving up. A systemctl status showing failed therefore remains the signal to watch, and a repeated failure indicates an expired certificate.

Symptom, on every GNOME workstation startup:

warning: not applying UID change of user 'gdm-greeter-2' (60580 -> 60579)

nixpkgs renumbered its gdm-greeter* accounts; NixOS never renumbers an existing account. Workstations installed before keep the old UIDs, and two greeters can end up sharing the same one.

Fenêtre de terminal
just fix-gdm-greeters poste-01,poste-02 # diagnostic, writes nothing
just fix-gdm-greeters poste-01,poste-02 apply

apply stops GDM, recreates the misaligned accounts with the declared UIDs, reassigns their files, then restarts GDM. A host with an open graphical session is left aside: restart after logging out. Backup of /etc/passwd and /etc/shadow in /var/lib/nixos/backup-gdm-greeters-<date>/.