feat(docker): decouple container restarts, add auto-update timer, and relocate chaos workloads (#271) #277
No reviewers
Labels
No labels
area:authentication
area:flake-utilities
area:performance
area:tbd
host:chaos
host:cosmos
host:electra
host:fleet
host:lena
host:lyra
host:mass-storage
host:media1
host:nimmog-de
host:nova
host:pangolin
host:pangolin-vps
host:phone
host:router
host:vega
investigation
phase:cutover
phase:deploy
phase:mcp
phase:module
phase:packaging
phase:prep
phase:validation
priority:high
priority:medium
project:attic-postgres-lyra-rollout
project:auto-update-reliability
project:auto-update-remediation
project:declarative-purity-cleanup
project:external-review
project:fleet-boundary-cleanup
project:host-facts-refactor
project:lyra-nixos-deploy
project:lyra-service-stack-migration
project:nebula-mesh-network
project:nix-idioms-hygiene
project:nixos-build-deployment-pipeline
project:security-hardening
project:service-stack-migration
project:vega-sillytavern-cutover
project:wiki-rebuild
repo:numtide/flake-utils
repo:numtide/nix-auth
repo:numtide/nixos-passthru-cache
repo:numtide/nix-relay
service:auto-update
service:gitlab
service:hermes
service:mem0
service:nix
service:sillytavern
service:slskd
service:synthseek
service:tdarr
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
nimmo/nixos-config!277
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/issue-271-container-auto-update"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Resolves #271.
This PR implements two core enhancements and relocates container workloads away from decommissioned host
chaos:Decouple container
restartTriggersfromconfigurationRevision(#271):restartTriggers = [ (pkgs.writeText "<name>-configuration-revision" configurationRevision) ];across all modules inmodules/containers/(killarr,paseo-relay,paseo-webui,plexdrome,rangarr,slskd,synthseek).builtins.hashFile "sha256") or standard systemd unit definition changes now govern service restarts instead of every single Git commit SHA update causing container restarts across the fleet.Nightly Docker & Compose auto-update timer:
modules/virtualization/docker-auto-update.nixwith a systemd timer running daily at 02:00./srv/stacks/*/docker-compose.ymlcompose projects, pulls updated images, and restarts only containers whose images changed.Chaos workload relocation to Lyra and Vega:
slskd,synthseek,plexdrome) tohosts/lyra/default.nix.killarr,rangarr,paseo-webui) tohosts/vega/default.nix.slskdstate directory creation for incomplete downloads.75for SynthSeek HTTP,76for Soulseek TCP) to point to Lyra (siteId: 17,lyra-nixos).Validation
nix flake checkpassed cleanly on all hosts (electra,lena,vega,lyra,chaos).just test):docker-rangarr,docker-killarr,docker-paseo-webui, anddocker-auto-update.timerare all active and healthy.just test):docker-synthseek,docker-plexdrome,docker-slskd, anddocker-auto-update.timerare all active and healthy.seek.nimmog.ukviacurl -sI https://seek.nimmog.uk(HTTP/2 200 OK) and SynthSeek MCP API (synthseek.get_system_healthreports all subsystems healthy).Automated code review
Reviewed commit:
81771f05015aa3821c4fbbd50786d8b486d6c4efVerdict: Requires further work
Resolve the blocking or important findings and investigate failed deterministic checks before merging.
Overall assessment
The PR migrates container workloads from the decommissioned
chaoshost tolyraandvega, updates SOPS secrets to reflect new host keys, and introduces a nightly Docker auto-update mechanism. The changes include removing configuration revision-based restart triggers in favor of image ID comparison for auto-updates, adding robust error handling, and ensuring directory existence via tmpfiles rules.Blocking findings
None.
Important findings
The
updateScriptdefinition includespkgs.docker-composeinruntimeInputs. However, the script logic explicitly checks fordocker compose(CLI plugin) first and falls back todocker-composeonly if the plugin is missing. The script does not usedocker-composedirectly as a command but relies on thecompose_execwrapper which detects availability at runtime. More critically, ifdocker composeis available,docker-composebinary is never invoked. If it's not available, the script skips stacks entirely. Thus,pkgs.docker-composeis effectively dead code in the standard path.Impact: Increases build time and closure size unnecessarily by including the standalone docker-compose package even when only the CLI plugin is used or needed.
Suggested fix: Remove
pkgs.docker-composefromruntimeInputs. The script's fallback logic handles the absence of the binary correctly without needing it in the closure if the plugin is present. If the standalone binary is strictly required for some edge case not covered by the plugin, ensure the wrapper explicitly uses it and document why.Suggestions
The logic
elif [ -z "$stack_images" ] && echo "$pull_output" | grep -qE "(Downloaded newer image|Pulled|pulled)"; then updated=trueallows updating ifstack_imagesis empty (e.g., due to config error or no images defined) but the pull output suggests activity. This can lead to unnecessary container recreation if the compose file is malformed or has no services, yet Docker reports 'Downloaded newer image' for some other reason (e.g., base image pull).Impact: Potential spurious restarts of containers in stacks with configuration issues or empty service definitions.
Suggested fix: Add a check to ensure
stack_imagesis not empty before relying on the grep fallback, or log a warning ifstack_imagesis empty but pull output indicates activity.Tests and validation
Questions
docker-auto-updatescript been tested on hosts where only thedocker composeCLI plugin is installed (without the standalonedocker-composebinary) to ensure the fallback logic does not fail silently or include unnecessary dependencies?/srv/stacksthat might have empty service definitions or configuration errors that could trigger the false-positive update path?Review limitations
nix flake checkorjust testto validate the configuration.lyraandvega.Diff coverage
.sops.yaml: reviewed — included in a context-limited batchhosts/chaos/default.nix: reviewed — included in a context-limited batchhosts/lyra/default.nix: reviewed — included in a context-limited batchhosts/vega/default.nix: reviewed — included in a context-limited batchjustfiles/secrets.just: reviewed — included in a context-limited batchmodules/containers/killarr.nix: reviewed — included in a context-limited batchmodules/containers/paseo-relay.nix: reviewed — included in a context-limited batchmodules/containers/paseo-webui.nix: reviewed — included in a context-limited batchmodules/containers/plexdrome.nix: reviewed — included in a context-limited batchmodules/containers/rangarr.nix: reviewed — included in a context-limited batchmodules/containers/slskd.nix: reviewed — included in a context-limited batchmodules/containers/synthseek.nix: reviewed — included in a context-limited batchmodules/virtualization/docker-auto-update.nix: reviewed — included in a context-limited batchmodules/virtualization/docker.nix: reviewed — included in a context-limited batchsecrets/plexdrome.yaml: reviewed — included in a context-limited batchsecrets/slskd.yaml: reviewed — included in a context-limited batchsecrets/synthseek.yaml: reviewed — included in a context-limited batchReview metadata
Addressed the findings from the automated code review in commit
81bf4c0:Rangarr & Killarr configuration directory creation:
systemd.tmpfiles.rules(d ${builtins.dirOf cfg.configFile} 0755 ${user} users -) to bothmodules/containers/rangarr.nixandmodules/containers/killarr.nixso the parent directory is guaranteed to exist regardless of host-level tmpfiles rules.preStartscripts todocker-rangarr.serviceanddocker-killarr.serviceensuringmkdir -pis run and touching the config file if absent to prevent Docker daemon bind-mount fallback from creating empty directories.Docker auto-update image detection hardening:
docker inspect --format '{{.Id}}' "$image") before and afterdocker pull. Container units are restarted only when the image ID changes.echo "WARNING: Failed to pull image..." >&2) so pull failures surface in the systemd journal rather than failing silently./srv/stacks.Validation:
nix flake checkpassed cleanly across all hosts.Addressed the updated automated review finding in commit
7b8240c:compose_execshell wrapper inmodules/virtualization/docker-auto-update.nixthat detects whetherdocker compose(CLI plugin interface) ordocker-compose(standalone binary) is available on the system, gracefully falling back between them and logging a notice if neither is found before inspecting/srv/stacks.nix flake checkpassed cleanly across all configurations and checks.Addressed the findings from the automated code review update:
SOPS Recipient Verification (Clarification on Important Finding):
secrets/slskd.yaml,secrets/synthseek.yaml,secrets/plexdrome.yaml) were verified directly. The oldchaoskey (age1zxvzxl2ffph32hpl3f5v226nvppm903ef6943uqy0l2jgk28t37sd4tv6k) is not present in any of the files.lyra(age1sxaj9le979k69925p7emxr34m6r78xd9ksnzeuytxm9szzymrgdqhm26kh)age1yubikey...)age1vlc2eans...)- recipient: age1zxvz...being replaced by+ recipient: age1sxaj..., confirming the chaos key was stripped upon re-encryption withsops updatekeys.Pre-up Hook Error Handling (
6c1f898):modules/virtualization/docker-auto-update.nix, updated the execution of stackpre-up.shhooks to check exit status and emit a warning to stderr (WARNING: pre-up.sh in stack '$stack_name' exited with non-zero status...) rather than silently discarding failures with|| true.Timer Target Scope:
modules/virtualization/docker-auto-update.nix,docker-auto-update.timerand its service are guarded bymkIf (config.virtualisation.docker.enable && cfg.enable). Non-Docker hosts (electra,lena) do not have Docker enabled and therefore do not instantiate the timer or generate journal noise.Validation:
nix flake checkpassed cleanly across all host configurations and checks.Addressed the remaining suggestion in commit
5841229:justfiles/secrets.just, updated bothedit-secrets-provisioningandupdatekeys-provisioningto check forPROVISIONING_AGE_KEYorSOPS_AGE_KEYin the environment before prompting interactively.nix flake checkpassed cleanly across all host configurations and checks.Addressed the findings from the latest automated review update in commit
81771f0:Robust image ID comparison for Compose stacks:
modules/virtualization/docker-auto-update.nixto discover defined images withcompose_exec config --imagesand compare their image IDs (docker inspect --format '{{.Id}}' "$img") before and after pulling.Auto-update hold support:
/run/docker-auto-update-hold,/etc/docker-auto-update-hold, and the shared deployment hold/run/nixos-auto-update/hold.virtualisation.docker.autoUpdate.hold(defaulting tofalse) for pausing container updates during maintenance windows.Validation:
nix flake checkpassed cleanly across all host configurations and checks.81771f05010652e3e4bbAddressed the feedback from the automated review and rebased onto
main:Rebase onto
main:origin/main(bdd4a9e), incorporating the latestflake.lockupdates pushed tomain.Clean up dependencies in
docker-auto-update.nix:pkgs.docker-composefromruntimeInputsinmodules/virtualization/docker-auto-update.nix.pkgs.dockerprovides the Docker Compose V2 plugin interface (docker compose) directly, eliminating the redundant package from the updater's closure.Compose stack update detection cleanup:
stack_imagesto be discovered and an image ID change (old_ids != new_ids) to be confirmed, emitting a warning if no images could be resolved.Validation:
nix flake checkpassed cleanly across all host configurations and checks following the rebase.