mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-19 19:01:42 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user