Skip to content

feat: runtime hostname management via display name#728

Merged
MSchmoecker merged 4 commits into
masterfrom
fix/runtime-hostname
Jun 15, 2026
Merged

feat: runtime hostname management via display name#728
MSchmoecker merged 4 commits into
masterfrom
fix/runtime-hostname

Conversation

@elikoga

@elikoga elikoga commented Jun 9, 2026

Copy link
Copy Markdown
Member

Problem

Device hostnames were only set at build time. There was no way to change the hostname at runtime, and no persistent mechanism for runtime changes.

Solution

When a user sets a device display name in the UI, the hostname is propagated to the device at runtime:

NixOS module (nix/thymis-device-nixos-module.nix)

  • tmpfiles rule creates /etc/hostname with ${cfg.device-name}-????-???? pattern on first boot (systemd fills ? from machine ID hash)
  • networking.hostName restored to cfg.device-name so NixOS activation writes the correct hostname
  • systemd path unit watches /etc/hostname for changes and triggers the apply service
  • systemd service runs hostname -F /etc/hostname on boot and on file changes

Agent (agent/thymis_agent/agent.py)

  • New RtEUpdateHostnameMessage relay message type
  • Handler writes hostname to /etc/hostname (persistent) and calls hostname command (immediate)

Controller relay (controller/thymis_controller/network_relay.py)

  • Sends current hostname to agent on connect (after SSH verification)
  • Uses shared sanitize_hostname() from lib.py

Controller API (controller/thymis_controller/routers/api_deployment_info.py)

  • When deployment_info.name changes via PATCH, sends hostname update to the connected agent
  • Empty/null names are skipped (no hostname update sent)

Frontend

  • Shows hostname update status indicator (updating → done) when device is online and name is changed
  • i18n strings added for en/de

Tests

  • Added FakeNetworkRelay to route test conftest to cover the new NetworkRelayAD dependency

@elikoga elikoga force-pushed the fix/runtime-hostname branch 2 times, most recently from eaaed4b to 837f811 Compare June 9, 2026 12:42
@MSchmoecker MSchmoecker force-pushed the fix/runtime-hostname branch from 837f811 to 45727aa Compare June 9, 2026 13:11
@elikoga elikoga force-pushed the fix/runtime-hostname branch 3 times, most recently from be1b4bc to 97e9fe9 Compare June 9, 2026 13:48
elikoga and others added 4 commits June 15, 2026 07:41
- NixOS module: tmpfiles rule creates /etc/hostname with
  '${cfg.device-name}-????-????' pattern (systemd fills ? from machine ID).
  networking.hostName restored to cfg.device-name (NixOS writes /etc/hostname
  at activation; tmpfiles C type only creates if missing).
  systemd path+service watches /etc/hostname for changes and applies.

- Agent: new RtEUpdateHostnameMessage handler writes /etc/hostname
  (persistent) and calls hostname command (immediate).

- Controller relay: sends current hostname on agent connect.

- Controller API: sends hostname update when deployment_info name changes.
  Hostname sanitization deduplicated in lib.py (shared by relay and API).
  Empty/null names are skipped (no hostname update sent).
  Route is async to support awaiting the WebSocket send.

- Frontend: shows hostname update status indicator when device is online.
  Added helper text explaining that name changes also update hostname.
  i18n strings added for en/de.

- Tests: add FakeNetworkRelay to route test conftest.
@MSchmoecker MSchmoecker force-pushed the fix/runtime-hostname branch from 5475215 to aa0dff7 Compare June 15, 2026 05:41
@MSchmoecker MSchmoecker added this pull request to the merge queue Jun 15, 2026
Merged via the queue into master with commit 8591e7c Jun 15, 2026
21 checks passed
@MSchmoecker MSchmoecker deleted the fix/runtime-hostname branch June 15, 2026 06:25
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