Skip to content

feat(range): keep gandalf on, stop ragnarok on a timer (ADR-0125) - #1652

Merged
Gerrrt merged 3 commits into
mainfrom
gerrrt/gandalf-always-on
Nov 23, 2026
Merged

Gerrrt merged 3 commits into
mainfrom
gerrrt/gandalf-always-on

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 23, 2026

Copy link
Copy Markdown
Owner

What changed

Policy: gandalf stays on, and the attack VM stops on a timer. ADR-0125 supersedes ADR-0124 the day it was accepted.

  • scripts/range-poweroff.sh becomes scripts/ragnarok-stop.sh, and systemd/range/'s units are renamed to match.
    • The deadline is six hours after ragnarok (VMID 130) starts. range-extend H still sets it 1 to 12 hours ahead. The extension is stored with the QEMU process's PID, so it never carries into the next start.
    • The warnings at 30 and 5 minutes also go inside the VM, through the guest agent.
    • The dpkg wait asks the agent about the VM's lock.
    • The stop is qm shutdown --timeout 180 --forceStop 1.
    • The service swaps the blanket ProtectSystem=strict for explicit writable paths that qm needs, and gets TimeoutStartSec=300.
  • ADR-0124 is marked Superseded. ADR-0017 gets a note: its "no monitoring" reason (a host off by design) is gone.
  • #1651, monitoring gandalf, is opened and replaces Power gandalf off on a timer (ADR-0124) #1647 on the roadmap.
  • build-the-playground.md:
    • §7 is rewritten for an always-on host. It installs the new timer and removes the old one.
    • §1 keeps After Power Loss: Power Off, with ADR-0125's reason.
    • The Not yet applied markers in §2 and §4 are replaced with what was run and read back.
    • §4's SSH login tests carry -o ControlPath=none.
    • §4's removal gains a second rm for the residue the first one missed.
    • §8 records check four.
  • The current-state docs that said "off between sessions" for gandalf now say it stays on: hardware.md, network.md, architecture.md, shut-down-on-the-ups.md, and the rack diagram with its PNG.
  • scripts/README.md, systemd/README.md and scripts/self-tests.sh are updated, and README's ADR count is 125.
  • The changelog has two 2026-11-22 entries: the fixes applied, and the policy change.

Why

The owner would rather gandalf stay on, with Kali off until it's needed. ADR-0124's own Context names the exposure: ragnarok on VLAN 30. A host that powers itself off makes every session start at the rack, because the BIOS powers on only at the button and AMT is disabled.

The other findings from the 2026-11-22 audit were applied on the box in the same session, so the runbook now records them as done. The cost ADR-0125 accepts is a host firewall nobody checks while the box is up, until #1651. That's why #1651 is opened now rather than left as an idea.

Closes #1647.

Refs #421, #1651.

Blast radius

gandalf only. The new timer can stop ragnarok, which is the point. It never touches the host or the targets.

Verification

  • make validate passes. It wasn't run, because this Mac has no docker daemon. What ran:
    • python3 scripts/check_docs.py: docs OK.
    • markdownlint-cli2 0.24.1 through npx: 0 issues.
    • shellcheck on the script: clean.
    • bash scripts/ragnarok-stop.sh --self-test: 22 pass on macOS, where the 2 lock interleavings skip with no flock. On gandalf, all 25 checks pass.
    • Two deliberate breaks each failed a fixture: an extension that ignores the PID, and a stopped VM that keeps its extension.
    • ./scripts/lint.sh: yamllint, ruff, shellcheck and actionlint pass (the last two are local binaries, not the pinned ones). markdownlint, zizmor, packer, tofu and editorconfig-checker were skipped with no docker. ansible-lint FAILED on the same local runner error as docs(range): write gandalf's 2026-11-22 audit fixes into the runbook #1646 (--pip-args contains '-c'). This PR touches no Ansible.
  • Deployed to the lab and confirmed working. The timer was installed on gandalf at 19:26, replacing ADR-0124's, and proved at 19:32 with a deadline a few minutes out:
    • It sent the 5-minute warning.
    • It logged deadline … has passed; stopping ragnarok, and the qmshutdown task ended OK in 2 seconds under the unit's sandbox.
    • Afterwards, status read not running, and range-extend refused with exit 1.
    • Not observed: a warning reaching a shell inside the VM, because none was open (the guest agent's wall returned 0).
    • The installed script and both units match this branch by sha256sum.
    • Also on the box tonight, all recorded in the runbook: §2 and §4 applied, a reboot read-back, and §8 check four from a throwaway clone.
  • Docs updated

🤖 Generated with Claude Code

ADR-0125 supersedes ADR-0124. The host stays on. The power-off timer is
retargeted at the attack VM: scripts/ragnarok-stop.sh stops VM 130 six
hours after it starts, or at the deadline the last range-extend set for
that run, with warnings on the host and inside the VM and a dpkg wait
asked through the guest agent. Installed and proved on gandalf.

The runbook records the audit fixes applied on gandalf the same evening
(§2, §4, the reboot read-back and §8 check four), and the current-state
docs drop "off between sessions" for the host. Monitoring the host is
Refs #1651.

Closes #1647.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 03:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical shutdown race can stop a replacement VM run using an expired deadline, while unstable deadline calculations can repeat warnings and timer activation can prematurely stop an overdue VM.

3 open issues
What changed in this PR

Implements ADR-0125: keep the range host gandalf running while moving the automatic shutdown deadline to its attack VM, ragnarok.

Changes:

  • Replaces host power-off automation with a VM stop timer, per-run extensions, guest warnings and package-install checks.
  • Updates installation procedures and records deployed hardening and timer verification.
  • Documents the new operating policy and tracks host monitoring separately in #1651.
File Description
systemd/​README.md Documents the VM stop timer.
systemd/​range/​homelab-range-poweroff.service Removes the host power-off service.
systemd/​range/​homelab-ragnarok-stop.timer Retargets minute-by-minute checks to the VM.
systemd/​range/​homelab-ragnarok-stop.service Adds the VM stop service and writable paths.
scripts/​self-tests.sh Updates fixture-suite documentation.
scripts/​README.md Describes VM deadlines and extensions.
scripts/​range-poweroff.sh Removes host shutdown automation.
scripts/​ragnarok-stop.sh Implements VM deadline enforcement and fixtures.
README.md Updates the ADR count to 125.
docs/​runbooks/​shut-down-on-the-ups.md Reflects the always-on range host.
docs/​runbooks/​build-the-playground.md Updates timer installation and records deployment checks.
docs/​roadmap.md Replaces power-off work with monitoring follow-up.
docs/​network.md Updates the range host’s operating policy.
docs/​hardware.md Updates the KVM table’s host description.
docs/​diagrams/​current/​rack-32u.svg Removes the off-between-sessions label.
docs/​changelog.md Records the policy change and applied audit fixes.
docs/​architecture.md Describes the always-on host and VM deadline.
docs/​adr/​0125-keep-gandalf-on-and-stop-ragnarok-on-a-timer.md Defines the new policy and accepted costs.
docs/​adr/​0124-power-gandalf-off-on-a-timer.md Marks host power-off policy superseded.
docs/​adr/​0017-buy-ifrit-for-iops-and-keep-the-range-disposable.md Notes the policy change and monitoring follow-up.

Review effort: Balanced

Comment thread scripts/ragnarok-stop.sh Resolved
Comment thread scripts/ragnarok-stop.sh Resolved
Comment thread docs/runbooks/build-the-playground.md Resolved
Gerrrt and others added 2 commits November 22, 2026 19:43
…tover

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… time

Review on #1652:
- Read the PID again just before qm shutdown, so a VM restarted during
  the guest-agent calls is not stopped by the old run's deadline.
- Take the start time from /proc/<pid>/stat instead of now minus
  ps etimes, which could move by a second and repeat a warning.
- §7 enables the timer last, after status and a chance to extend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt enabled auto-merge (squash) November 23, 2026 03:55
@Gerrrt
Gerrrt merged commit d216463 into main Nov 23, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/gandalf-always-on branch November 23, 2026 04:00
Gerrrt added a commit that referenced this pull request Nov 23, 2026
…y volume list

Review on #1653:
- Restore the #1652 audit-fixes changelog entry verbatim and record the
  leftovers cleanup in a new dated entry that names it, per the changelog's
  own immutability rule.
- The local-lvm removal now lists the data pool's thin volumes and requires
  none, instead of reading Data% 0.00 (which an unwritten thin volume also
  shows).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Power gandalf off on a timer (ADR-0124)

2 participants