Skip to content

fix(nix): upgrading moq-auth restarts the relay through its handoff - #9065

Merged
kixelated merged 3 commits into
mainfrom
quest/m1/precut-fixes/nix-auth-restart
Nov 18, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m1/precut-fixes/nix-auth-restart

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

With services.moq-relay.handoff on, moq-auth is requiredBy the relay and kept the default stopIfChanged = true. Its ExecStart names the moq-cli store path, so nearly every upgrade changes it. When you switch, moq-auth stops, Requires= passes the stop on to the relay, and the relay drains every session and starts with no handoff.

Approach

moq-auth now sets stopIfChanged = false. A switch restarts it in place, and the restart reaches the relay as a restart job. The relay already handles a restart through its handoff (RestartKillSignal = SIGUSR2). This is set without a condition: when handoff is off, the relay restarts cold either way.

Impact

  • Public API: none. Wire: none.
  • Behavior: on a handoff relay, a switch that changes moq-auth keeps the relay's sessions. A switch that changes only moq-auth now restarts the relay through its handoff instead of stopping it.

Alternatives

  • wants instead of requiredBy: rejected by the maintainer (moq-dev/moq#9010). It lets the relay run with no auth server, and the relay then refuses every session.

Validation

There is no NixOS VM test for the module, so I wrote a throwaway runNixOSTest (not checked in). The node runs the module with handoff = true, auth.enable = true, and tls.generate = [ "localhost" ]. A next specialisation changes both units' environment, and the test switches to it with switch-to-configuration test.

  • Before the fix, switch-to-configuration printed stopping the following units: moq-auth.service / restarting ...: moq-relay.service / starting ...: moq-auth.service. The old relay logged shutdown signal received; draining sessions (SIGTERM). The new one logged no relay to take over from; binding every listener. The test's wait for a handoff timed out.
  • After the fix, it printed restarting the following units: moq-auth.service, moq-relay.service. The stand-in logged leaving the relay to drain beside the one replacing it. The new relay logged taking over from the relay already serving and serving beside the relay this one replaces; it drains now. The old one logged handed every socket to the relay taking over sockets=4. The test passed.
  • just check passed.

Caused by

  • moq-dev/moq#8596 - added handoff while moq-auth stayed a required unit with stopIfChanged = true, so its stop cut the relay (found by check: 2026-11-17 pre-cut correctness audit)

Follow-ups

None.

Models

Size: XS
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm B)
Implementer: Claude Code, claude-opus-5-5, medium effort (iterate, XS, arm B)

🤖 Generated with Claude Code

(Written by Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 2273970

  • Base: origin/main at 4bcae73

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1ecef-50fe-72c1-a34c-dfaca05d75f9, round 2

  • Score: 9/10, The only change since the last review clarifies that session preservation requires handoff, with no actionable defects found; runtime validation remains unverified.

  • Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 17, 2026 19:55
moq-auth is required by the relay and stopped on change, so nearly every
switch stopped it and the stop propagated to the relay, which drained every
session and bound cold. Restart it in place instead: the restart propagates
as a restart, which the relay survives through SIGUSR2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Upgrading the NixOS moq-auth unit restarts the relay through its handoff fix(nix): upgrading moq-auth restarts the relay through its handoff Nov 18, 2026
@kixelated
kixelated marked this pull request as ready for review November 18, 2026 04:35
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The moq-auth systemd service sets stopIfChanged = false. Comments describe stop and restart propagation from moq-auth to moq-relay. The related planning document is deleted.

Merge Risk: Minimal · up to 22739

Upgrading moq-auth will restart it in place, so the relay is restarted rather than stopped. Sessions are preserved only when handoff is enabled. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: upgrading moq-auth now restarts the relay through its handoff instead of stopping it. The raw summary confirms the moq-auth stopIfChanged change in nix/modules/moq-rel…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the problem (moq-auth with stopIfChanged = true cuts the relay on switch under handoff), the approach (set stopIfChanged = false so the switch restarts the relay through its han…
Full details: Title check

Explanation

The title names the main change: upgrading moq-auth now restarts the relay through its handoff instead of stopping it. The raw summary confirms the moq-auth stopIfChanged change in nix/modules/moq-relay.nix, which matches the title's fix.

Full details: Description check

Explanation

The description states the problem (moq-auth with stopIfChanged = true cuts the relay on switch under handoff), the approach (set stopIfChanged = false so the switch restarts the relay through its handoff), the impact, alternatives, validation steps, and the commit that caused the issue. It is clearly related to the changeset, which sets stopIfChanged = false in nix/modules/moq-relay.nix. The check passes.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4fe1b8e-3b39-4e0f-ae20-b40f29756855
Commits

Reviewing files that changed from the base of the PR and between 6a145b0 and 2273970.

Files selected for processing: 2

  • nix/modules/moq-relay.nix
  • quest/m1/precut-fixes/nix-auth-restart.md
Files with no reviewable changes: 1

  • quest/m1/precut-fixes/nix-auth-restart.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one comment nit inline.

Approach: sound — stopIfChanged = false turns moq-auth's switch-time stop into a restart, which systemd propagates to the required relay as a try-restart, so a handoff relay hands over its sockets instead of draining.

Reviewed changes

  • moq-auth restarts instead of stopping — nix/modules/moq-relay.nix sets stopIfChanged = false, so an upgrade that changes its ExecStart (the moq-cli store path) no longer stops the unit, and Requires= no longer propagates that stop to moq-relay.
  • Quest file removed — quest/m1/precut-fixes/nix-auth-restart.md is deleted as the quest lands, matching how other precut fixes land.

I traced the mechanism through the flake's nixpkgs (systemd-lib.nix emits X-StopIfChanged=false, switch-to-configuration-ng's handle_modified_unit schedules a restart job for it) and systemd (transaction.c propagates JOB_RESTART along UNIT_ATOM_PROPAGATE_STOP as JOB_TRY_RESTART, and UNIT_REQUIRED_BY carries that atom), so the restart does reach the relay and the ordering follows after = [ "moq-auth.service" ]. Setting it unconditionally is also right: with handoff off the relay gets a cold restart rather than the old propagation stopping it, which is strictly better.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

Comment thread nix/modules/moq-relay.nix Resolved
…h handoff on

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — since the prior pullfrog review at e25c3210e, the delta is two comment lines in nix/modules/moq-relay.nix; the code hunk and the quest file deletion are unchanged.

  • Reworded the stopIfChanged = false comment to scope the session-preserving behavior to a handoff relay, noting the restart is cold otherwise. This resolves the earlier inline nit, and the new wording matches the systemd propagation path: moq-auth's restart reaches the required relay as a try-restart, which is a socket handoff only when RestartKillSignal = SIGUSR2 is set for handoff = true.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 7260f4c Nov 18, 2026
9 checks passed
@kixelated
kixelated deleted the quest/m1/precut-fixes/nix-auth-restart branch November 18, 2026 06:32
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.

1 participant