Fix stale DNS zone after wizard completes (#8)
Unit Tests / test (push) Successful in 7m29s

_bootstrap_dns runs at container start before the wizard, writing the
default cell name ('mycell') into cell.zone.  When the wizard completed
it fired IDENTITY_CHANGED for Caddy but never updated the DNS zone, so
DNS records kept showing 'mycell.cell' even after naming the cell.

After successful wizard completion, call network_manager.apply_cell_name
to rename the hostname record in the primary zone file, then reload
CoreDNS.  The empty old_name triggers auto-detection so it works even
when the zone was written with the env-var default.

Adds test_setup_route.py covering: apply_cell_name called on success,
not called on failure, 410 on repeat completion, and IDENTITY_CHANGED
publication.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 05:14:22 -04:00
parent 3d750ed1e8
commit c1e93f2058
2 changed files with 139 additions and 2 deletions
+6 -2
View File
@@ -90,15 +90,19 @@ def complete_setup():
result = sm.complete_setup(payload)
if result.get('success'):
try:
from app import config_manager, service_bus, EventType
from app import config_manager, service_bus, EventType, network_manager
identity = config_manager.configs.get('_identity', {})
cell_name = identity.get('cell_name', '')
service_bus.publish_event(EventType.IDENTITY_CHANGED, 'setup', {
'cell_name': identity.get('cell_name'),
'cell_name': cell_name,
'domain': identity.get('domain'),
'domain_name': identity.get('domain_name'),
'domain_mode': identity.get('domain_mode'),
'effective_domain': config_manager.get_effective_domain(),
})
# Bootstrap wrote the zone with 'mycell'; rename to the real cell name.
if cell_name:
network_manager.apply_cell_name('', cell_name)
except Exception as exc:
logger.warning(f'Failed to publish IDENTITY_CHANGED after setup: {exc}')
status_code = 200 if result.get('success') else 400