fix(vpcd): store spinifex:cidr on VPC create (mulga-siv-106)

handleVPCCreate built the OVN logical router with only spinifex:vpc_id
and spinifex:vni in ExternalIDs. Cleanup paths (handleIGWDetach + NAT
sweeps) read external_ids['spinifex:cidr'] to scope SNAT removal to
the VPC's own CIDR; when unset, they fell back to an overbroad
10.0.0.0/8 and emitted a WARN.

reconcileVPC already stored the same key at startup; the live-create
path drifted. Add the field to handleVPCCreate, log the cidr alongside
vpc_id, extend TestTopologyHandler_VPCCreate to assert the external_id
is set.

Refs: mulga-siv-106
This commit is contained in:
joshsiv-mulga
2026-05-19 09:23:38 +10:00
parent 5abf76019a
commit f142dc07c4
2 changed files with 10 additions and 1 deletions
+7 -1
View File
@@ -526,6 +526,12 @@ func (h *TopologyHandler) handleVPCCreate(msg *nats.Msg) {
ExternalIDs: map[string]string{
"spinifex:vpc_id": evt.VpcId,
"spinifex:vni": strconv.FormatInt(evt.VNI, 10),
// Cleanup paths (handleIGWDetach, NAT sweeps) read this to scope
// their SNAT removal to the VPC's own CIDR. When unset, those
// paths fall back to an overbroad 10.0.0.0/8 and emit noisy
// "VPC CIDR missing from router metadata" WARNs. reconcileVPC
// stores the same key on startup; keep parity here.
"spinifex:cidr": evt.CidrBlock,
},
}
@@ -535,7 +541,7 @@ func (h *TopologyHandler) handleVPCCreate(msg *nats.Msg) {
return
}
slog.Info("vpcd: created logical router for VPC", "router", routerName, "vpc_id", evt.VpcId)
slog.Info("vpcd: created logical router for VPC", "router", routerName, "vpc_id", evt.VpcId, "cidr", evt.CidrBlock)
respond(msg, nil)
}
+3
View File
@@ -73,6 +73,9 @@ func TestTopologyHandler_VPCCreate(t *testing.T) {
if lr.ExternalIDs["spinifex:vni"] != "100" {
t.Errorf("expected vni external_id=100, got %v", lr.ExternalIDs["spinifex:vni"])
}
if lr.ExternalIDs["spinifex:cidr"] != "10.0.0.0/16" {
t.Errorf("expected cidr external_id=10.0.0.0/16, got %v", lr.ExternalIDs["spinifex:cidr"])
}
}
func TestTopologyHandler_VPCDelete(t *testing.T) {