fix(swarm-test): drop the backup host's mirrored network mode before it deploys

The VPN variants reset credentials with --mirror --backup in the mesh prologue, which copies the manager's host_vars onto the backup host again, NETWORK_MODE: multi included, after extend_inventory had stripped it. The backup deploy then failed in lookup('tls'): "NETWORK_MODE 'multi' needs svc-net-tor with a node onion on this node" (Meta#0, run 40131272595). The strip is now a helper that also runs right before the backup host deploys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-25 07:50:10 +01:00
1 parent 2ed1b03e1e
commit c691abe8a8
3 files changed
+43 -5

No files matched your search

@@ -6,6 +6,7 @@ import unittest.mock as mock
from pathlib import Path
from utils.tests.swarm import extend_inventory as ei
from utils.tests.swarm import matrix
class TestBackupLegGating(unittest.TestCase):
@@ -86,6 +87,34 @@ class TestBackupHostNetworkMode(unittest.TestCase):
def test_backup_vars_without_network_mode_stay_untouched(self):
self.assertEqual(self._backup_vars({"keep": 1}), {"keep": 1})
def test_a_mode_a_later_mirror_copied_back_is_dropped_again(self):
with tempfile.TemporaryDirectory() as td:
vars_path = Path(td) / "host_vars" / f"{ei._BACKUP}.yml"
vars_path.parent.mkdir()
ei.dump_yaml(str(vars_path), {"NETWORK_MODE": "multi", "keep": 1})
ei.drop_backup_network_mode(td)
self.assertEqual(ei.load_yaml_any(str(vars_path)), {"keep": 1})
def test_the_backup_deploy_runs_on_host_vars_without_a_network_mode(self):
seen: dict = {}
with tempfile.TemporaryDirectory() as td:
vars_path = Path(td) / "host_vars" / f"{ei._BACKUP}.yml"
vars_path.parent.mkdir()
ei.dump_yaml(str(vars_path), {"NETWORK_MODE": "multi", "keep": 1})
def deploy(**_kwargs):
seen.update(ei.load_yaml_any(str(vars_path)))
return 0
with mock.patch.object(matrix, "_run", side_effect=deploy):
matrix._deploy_backup_host(
app_id="web-app-meta", inv_dir=td, extras_path="extras.yml"
)
self.assertEqual(seen, {"keep": 1})
class TestSandboxWorkerLabelling(unittest.TestCase):
def _workers(self, kata_enabled: object) -> tuple[str, ...]: