feat: runtime hostname management via display name#728
Merged
Conversation
eaaed4b to
837f811
Compare
837f811 to
45727aa
Compare
be1b4bc to
97e9fe9
Compare
- 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.
5475215 to
aa0dff7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)
/etc/hostnamewith${cfg.device-name}-????-????pattern on first boot (systemd fills?from machine ID hash)networking.hostNamerestored tocfg.device-nameso NixOS activation writes the correct hostname/etc/hostnamefor changes and triggers the apply servicehostname -F /etc/hostnameon boot and on file changesAgent (agent/thymis_agent/agent.py)
RtEUpdateHostnameMessagerelay message type/etc/hostname(persistent) and callshostnamecommand (immediate)Controller relay (controller/thymis_controller/network_relay.py)
sanitize_hostname()fromlib.pyController API (controller/thymis_controller/routers/api_deployment_info.py)
deployment_info.namechanges via PATCH, sends hostname update to the connected agentFrontend
Tests
FakeNetworkRelayto route test conftest to cover the newNetworkRelayADdependency