Revert "feat(mazenet): host resolution + cross-host bridge guard"

This reverts commit 448fcd1227.
This commit is contained in:
2026-04-25 03:26:19 -04:00
parent 448fcd1227
commit e169b891d7
4 changed files with 1 additions and 195 deletions

View File

@@ -213,47 +213,6 @@ def _backfill_decky_configs(
decky["decky_config"] = cfg
def resolve_lan_host(
lan: dict[str, Any], topology: dict[str, Any]
) -> str | None:
"""Effective swarm host for a LAN.
A LAN is one Docker bridge — bridges don't span hosts — so this is
the single source of truth callers (deployer, mutator, validator)
consult before issuing per-host work.
Resolution order::
lan.host_uuid → topology.target_host_uuid → None (= master-local)
"""
h = lan.get("host_uuid") if lan else None
if h:
return h
return (topology or {}).get("target_host_uuid")
def partition_lans_by_host(
hydrated: dict[str, Any],
) -> dict[str | None, list[dict[str, Any]]]:
"""Group LANs by their effective host.
Keys are host UUIDs; ``None`` means master-local. Order of LANs
within each bucket follows the input order.
"""
out: dict[str | None, list[dict[str, Any]]] = {}
topology = hydrated.get("topology") or {}
for lan in hydrated.get("lans", []):
out.setdefault(resolve_lan_host(lan, topology), []).append(lan)
return out
# Re-export the status constants so callers can ``from decnet.topology.persistence
# import TopologyStatus`` without chasing modules.
__all__ = [
"persist",
"transition_status",
"hydrate",
"resolve_lan_host",
"partition_lans_by_host",
"TopologyStatus",
]
__all__ = ["persist", "transition_status", "hydrate", "TopologyStatus"]

View File

@@ -329,57 +329,6 @@ def check_no_host_port_collision(h: dict[str, Any]) -> list[ValidationIssue]:
return issues
def check_bridge_decky_same_host(
h: dict[str, Any],
) -> list[ValidationIssue]:
"""A multi-homed (bridge) decky is one container — its LANs must
therefore resolve to the same swarm host.
Without this, the deployer would have to either silently pick a
host for the bridge container (orphaning IPs on the other host's
LAN) or implement a cross-host overlay. The co-locate decision
rules out the overlay, so we reject the topology up front.
"""
from decnet.topology.persistence import resolve_lan_host
topology = h.get("topology") or {}
lans_by_id = {lan["id"]: lan for lan in h.get("lans", [])}
deckies_by_uuid = {d["uuid"]: d for d in h.get("deckies", [])}
decky_lans: dict[str, list[str]] = {}
for edge in h.get("edges", []):
decky_lans.setdefault(edge["decky_uuid"], []).append(edge["lan_id"])
issues: list[ValidationIssue] = []
for decky_uuid, lan_ids in decky_lans.items():
if len(lan_ids) < 2:
continue
hosts = {
resolve_lan_host(lans_by_id[lid], topology)
for lid in lan_ids
if lid in lans_by_id
}
if len(hosts) > 1:
decky = deckies_by_uuid.get(decky_uuid, {})
issues.append(
ValidationIssue(
"error",
"BRIDGE_HOST_SPLIT",
f"bridge decky {decky.get('name', decky_uuid)!r} is "
"attached to LANs assigned to different swarm hosts; "
"a single container cannot span hosts",
target={
"decky": decky.get("name"),
"lans": [
lans_by_id[lid].get("name")
for lid in lan_ids
if lid in lans_by_id
],
},
)
)
return issues
# Pure-data rules. Host-state rules (like PORT_COLLISION) are
# *not* listed here — they're called separately by the live deployer
# so that unit tests exercising validate() stay hermetic.
@@ -392,7 +341,6 @@ _RULES: list[Callable[[dict[str, Any]], list[ValidationIssue]]] = [
check_no_subnet_overlap,
check_services_known,
check_service_config_shape,
check_bridge_decky_same_host,
]