Skip to content

Restart miren.service after register instead of warning#824

Merged
phinze merged 1 commit into
mainfrom
phinze/mir-1155-dont-warn-about-restart-on-install
May 28, 2026
Merged

Restart miren.service after register instead of warning#824
phinze merged 1 commit into
mainfrom
phinze/mir-1155-dont-warn-about-restart-on-install

Conversation

@phinze
Copy link
Copy Markdown
Contributor

@phinze phinze commented May 27, 2026

The warning at the end of miren server register ("you must now restart the miren server") was the bug, but the fix had a couple of layers. The warning fires at the end of every Register call, including from inside miren install, which then turns around and starts the systemd unit itself a few lines later. So during install it's pure noise. During a standalone re-register against a live cluster it's at least correct, but easy to miss in all the other registration output.

I went down the rabbit hole of "could register just be online and not need a restart at all" first. Short version: the cloud authenticator gets wired into RPC server options at construction time with no swap path, plus the build and deployment servers read DNSHostname by value at startup. So it's a real refactor across the auth chain to make any of it dynamic. Maybe worth it someday, but registration is a once-a-quarter operation and the surface area is large.

What we landed on instead: detect a running systemd miren.service and restart it ourselves. Fresh installs (systemd or docker) hit the "unit isn't active yet" branch and stay quiet, since install handles the lifecycle a few lines later anyway. Standalone re-register against a live cluster gets an auto-restart plus a "Restarted miren.service" info line. The one case it still doesn't handle is day-2 re-register on a docker install, but docker is the demo path so it pretty much never happens. Left it.

Closes MIR-1155

@phinze phinze requested a review from a team as a code owner May 27, 2026 20:10
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 638b67c7-5a06-4995-8c86-67e72c8462c2

📥 Commits

Reviewing files that changed from the base of the PR and between 33178d2 and d64067c.

📒 Files selected for processing (2)
  • cli/commands/commands_linux.go
  • cli/commands/server_register.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cli/commands/server_register.go

📝 Walkthrough

Walkthrough

The Register command in the server registration flow now automatically restarts the local miren.service using systemctl after successfully saving an approved registration. A new helper function restartMirenServiceIfActive encapsulates the systemd detection logic, verifying that systemctl is available and the service is currently active before attempting restart. The prior behavior that required users to manually restart the server is removed, with appropriate warning and info logs emitted for various outcomes.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/commands/server_register.go`:
- Line 205: The resumed-pending-registration success branch returns early
without restarting the service, so call restartMirenServiceIfActive(ctx) in that
branch (the code path that handles resuming an existing pending registration and
currently returns before the fresh-registration restart call) — either insert
restartMirenServiceIfActive(ctx) immediately before the early return in the
resume/approve-pending branch or refactor both success paths to use a single
post-success handler that invokes restartMirenServiceIfActive(ctx) so the
restart runs for both fresh and resumed registrations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 055958f9-360a-4a0d-b470-7d1825ca96c1

📥 Commits

Reviewing files that changed from the base of the PR and between d88b862 and 09810df.

📒 Files selected for processing (1)
  • cli/commands/server_register.go

Comment thread cli/commands/server_register.go Outdated
@phinze phinze force-pushed the phinze/mir-1155-dont-warn-about-restart-on-install branch from 09810df to 33178d2 Compare May 27, 2026 20:42
Copy link
Copy Markdown
Contributor

@evanphx evanphx left a comment

Choose a reason for hiding this comment

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

We call Register directly from Install as we're doing the install, so I'm worried that a restart here will cause unnecessary churn while the system is trying to come up for the first time.

Copy link
Copy Markdown
Contributor

@evanphx evanphx left a comment

Choose a reason for hiding this comment

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

Oops, missed the check. is-active being load berring for a proper install feels... weird but fine.

The "you must now restart" warning fired at the end of every Register
call, including from `miren install` where install handles the unit
lifecycle itself a few lines later. So the message was either noise
(during install) or easy to miss (after a standalone re-register against
a live cluster).

Detect a running systemd miren.service and restart it ourselves. When
systemctl isn't present or the unit isn't active (fresh install, docker,
dev, ad-hoc), stay silent — install or the operator already owns the
lifecycle in those cases. If the restart command fails, fall back to a
focused warning telling the user to bounce it manually.

Fixes MIR-1155.
@phinze phinze force-pushed the phinze/mir-1155-dont-warn-about-restart-on-install branch from 33178d2 to d64067c Compare May 27, 2026 20:59
@phinze
Copy link
Copy Markdown
Contributor Author

phinze commented May 28, 2026

Ya fair point, reworked it so we don't rely on is-active for the install case.

@phinze phinze merged commit 604a2f3 into main May 28, 2026
19 checks passed
@phinze phinze deleted the phinze/mir-1155-dont-warn-about-restart-on-install branch May 28, 2026 14:15
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.

2 participants