swarm-nats: the pod's raw rule lets through the interfaces the firewall opens the client port on
The hostPort's raw-table drop for the queue's client port let through only the host's loopback, the bridge and the pods' interfaces, so a hive on another host, reaching the queue over wg0 where the firewall's own rule opens the port, timed out. The rule now also returns for every interface whose networking.firewall.interfaces entry opens the port. semi-spread dumps the queue's network state when the hive cannot reach it, and asserts the port answers over wg0 and not on the public address.
This commit is contained in:
parent
bd7c261078
commit
4bb6c573ae
1 changed files with 98 additions and 8 deletions
|
|
@ -204,6 +204,32 @@ let
|
|||
diagnose(m, unit, container)
|
||||
raise
|
||||
|
||||
QUEUE_NAME = "${swarm.nats.domain}"
|
||||
QUEUE_PORT = ${toString swarm.nats.port}
|
||||
|
||||
def dials_queue(address):
|
||||
return f"timeout 5 bash -c 'exec 3<>/dev/tcp/{address}/{QUEUE_PORT}'"
|
||||
|
||||
def diagnose_queue():
|
||||
# Where a dial to the queue dies: what the swarm machine listens on and drops
|
||||
# in its raw table (with packet counters), the cluster's view of the queue's
|
||||
# Service, and what each machine resolves and routes the queue's name to.
|
||||
for m, command in [
|
||||
(swarm, "iptables -t raw -S"),
|
||||
(swarm, "iptables -t raw -L nixos-fw-nats -v -n"),
|
||||
(swarm, f"iptables -S | grep -E '{QUEUE_PORT}|wg0'"),
|
||||
(swarm, "ss -ltn"),
|
||||
(swarm, "k3s kubectl get pods,svc,endpoints,networkpolicy -A -o wide"),
|
||||
(hive, f"getent ahostsv4 {QUEUE_NAME}"),
|
||||
(heavyduty, f"getent ahostsv4 {QUEUE_NAME}"),
|
||||
(hive, f"ip route get $(getent ahostsv4 {QUEUE_NAME} | awk 'NR==1 {{print $1}}')"),
|
||||
(hive, dials_queue(QUEUE_NAME) + "; echo dial exit $?"),
|
||||
(heavyduty, dials_queue(QUEUE_NAME) + "; echo dial exit $?"),
|
||||
(swarm, dials_queue(QUEUE_NAME) + "; echo dial exit $?"),
|
||||
]:
|
||||
print(f"--- {m.name}: {command}")
|
||||
print(m.execute(command)[1])
|
||||
|
||||
HIVE_UNITS = ["hive-priv.socket", "hive-priv.service", "hive-c0re"]
|
||||
|
||||
def hive_fault():
|
||||
|
|
@ -284,6 +310,7 @@ let
|
|||
if fault:
|
||||
break
|
||||
time.sleep(10)
|
||||
diagnose_queue()
|
||||
diagnose(hive, HIVE_UNITS)
|
||||
diagnose(swarm, ["swarm-controller"])
|
||||
diagnose(heavyduty, "swarm-builder", "swarm-builder")
|
||||
|
|
@ -524,6 +551,17 @@ let
|
|||
# The public names are not on heavyduty or the hive either.
|
||||
assert http(outside, NAMES["forge"], "/api/healthz", resolve=LAN["heavyduty"]) == "000"
|
||||
|
||||
with subtest("the queue's port answers on the swarm machine and over wg0, and not on its public address"):
|
||||
# The control first: the pod listens, reached from the machine that runs it.
|
||||
try:
|
||||
swarm.wait_until_succeeds(dials_queue(QUEUE_NAME), timeout=900)
|
||||
for m in (hive, heavyduty):
|
||||
m.wait_until_succeeds(dials_queue(QUEUE_NAME), timeout=120)
|
||||
except Exception:
|
||||
diagnose_queue()
|
||||
raise
|
||||
assert outside.execute(dials_queue(LAN["swarm"]))[0] != 0, "the queue answers on the swarm machine's public address"
|
||||
|
||||
with subtest("the forge holds hyperhive/hyperhive at the fixture's commit"):
|
||||
settle(
|
||||
swarm,
|
||||
|
|
@ -793,6 +831,10 @@ pkgs.testers.runNixOSTest (
|
|||
bao.machine = "stub";
|
||||
dashboardDomains.${hiveName} = "dashboard.stub";
|
||||
attic.domain = "attic.stub";
|
||||
nats = {
|
||||
domain = "nats.stub";
|
||||
port = 4222;
|
||||
};
|
||||
};
|
||||
nameOf.stub = "stub.stub";
|
||||
internalNames.stub = "stub";
|
||||
|
|
|
|||
Loading…
Reference in a new issue