Skip to content

Commit dba6923

Browse files
committed
Require Fabric bum.defaultMulticastGroup and drop migration fallback
Signed-off-by: Sebastian Wagner <sebastian.wagner02@sap.com>
1 parent 0e707d2 commit dba6923

6 files changed

Lines changed: 30 additions & 82 deletions

File tree

‎api/evpn/v1alpha1/fabric_types.go‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const (
182182
// FabricBUMSpec defines how BUM (Broadcast, Unknown unicast, Multicast) traffic
183183
// is forwarded across the fabric.
184184
// +kubebuilder:validation:XValidation:rule="self.type != 'Multicast' || has(self.pim)",message="pim must be set when type is Multicast"
185-
// +kubebuilder:validation:XValidation:rule="self.type != 'Multicast' || !has(self.pim) || size(self.pim.anycastRendezvousPoints[0].multicastGroups) <= 1 || has(self.defaultMulticastGroup)",message="defaultMulticastGroup is required when the first rendezvous point serves more than one multicastGroups entry"
185+
// +kubebuilder:validation:XValidation:rule="self.type != 'Multicast' || has(self.defaultMulticastGroup)",message="defaultMulticastGroup is required when type is Multicast"
186186
type FabricBUMSpec struct {
187187
// type selects the BUM forwarding mechanism.
188188
// +required
@@ -193,11 +193,8 @@ type FabricBUMSpec struct {
193193
PIM *FabricPIMSpec `json:"pim,omitempty"`
194194

195195
// defaultMulticastGroup is the IPv4 multicast group programmed as the global
196-
// Layer 2 BUM mcast-group on every VTEP NVE. If unset, it is derived from the
197-
// first entry of the first pim.anycastRendezvousPoints group; this derivation
198-
// is a migration fallback for fabrics authored before this field existed and
199-
// is only allowed when that group serves a single multicastGroups entry,
200-
// otherwise the field is required. Per-VNI mcast-group overrides are not supported.
196+
// Layer 2 BUM mcast-group on every VTEP NVE. Required when type is Multicast.
197+
// Per-VNI mcast-group overrides are not supported.
201198
// +optional
202199
DefaultMulticastGroup *corev1alpha1.IPPrefix `json:"defaultMulticastGroup,omitempty"`
203200
}

‎charts/network-operator/templates/crd/fabrics.evpn.networking.metal.ironcore.dev.yaml‎

Lines changed: 4 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎config/crd/bases/evpn.networking.metal.ironcore.dev_fabrics.yaml‎

Lines changed: 4 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/api-reference/index.md‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/controller/evpn/fabric_controller.go‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,22 +1315,6 @@ func (r *FabricReconciler) reconcilePIM(ctx context.Context, deviceName string,
13151315
return nil
13161316
}
13171317

1318-
// nveL2MulticastGroup resolves the global Layer 2 BUM mcast-group for VTEP NVEs:
1319-
// spec.bum.defaultMulticastGroup if set, else the first PIM RP group as a fallback.
1320-
// Returns nil when BUM is not Multicast.
1321-
// FIXME: the RP-derivation fallback is migration-only; remove once all fabrics set
1322-
// spec.bum.defaultMulticastGroup.
1323-
func nveL2MulticastGroup(fabric *evpnv1alpha1.Fabric) *v1alpha1.IPPrefix {
1324-
if fabric.Spec.BUM.Type != evpnv1alpha1.BUMTypeMulticast {
1325-
return nil
1326-
}
1327-
if fabric.Spec.BUM.DefaultMulticastGroup != nil {
1328-
return fabric.Spec.BUM.DefaultMulticastGroup
1329-
}
1330-
// API validation guarantees PIM, an RP, and a group exist in the fallback case.
1331-
return &fabric.Spec.BUM.PIM.AnycastRendezvousPoints[0].MulticastGroups[0]
1332-
}
1333-
13341318
// reconcileVTEPNVE creates one NetworkVirtualizationEdge resource per VTEP device.
13351319
// The NVE references lo1 (primary VTEP) as source, and lo2 (anycast VTEP) as anycast
13361320
// source when spec.vtep.anycastVTEP is enabled.
@@ -1345,7 +1329,12 @@ func (r *FabricReconciler) reconcileVTEPNVE(ctx context.Context, fabric *evpnv1a
13451329
return ctrl.Result{}, fmt.Errorf("listing VTEP devices: %w", err)
13461330
}
13471331

1348-
l2Group := nveL2MulticastGroup(fabric)
1332+
// Global Layer 2 BUM mcast-group for VTEP NVEs; set only when BUM is Multicast
1333+
// (API validation guarantees the field is present in that case).
1334+
var l2Group *v1alpha1.IPPrefix
1335+
if fabric.Spec.BUM.Type == evpnv1alpha1.BUMTypeMulticast {
1336+
l2Group = fabric.Spec.BUM.DefaultMulticastGroup
1337+
}
13491338

13501339
for i := range devices.Items {
13511340
device := &devices.Items[i]

‎internal/controller/evpn/fabric_controller_test.go‎

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
poolv1alpha1 "github.com/ironcore-dev/network-operator/api/pool/v1alpha1"
2222
)
2323

24+
// defaultMulticastGroup is the BUM L2 mcast-group shared by the fabric test fixtures.
25+
var defaultMulticastGroup = corev1alpha1.MustParsePrefix("224.0.0.0/4")
26+
2427
// Minimal 2-spine / 2-leaf EVPN/VXLAN topology used by the tests below.
2528
// All four devices share the "topology.kubernetes.io/zone: test-zone" label;
2629
// the "role" label drives per-role loopback allocation.
@@ -198,7 +201,8 @@ var _ = Describe("Fabric Controller", func() {
198201
},
199202
},
200203
BUM: evpnv1alpha1.FabricBUMSpec{
201-
Type: evpnv1alpha1.BUMTypeMulticast,
204+
Type: evpnv1alpha1.BUMTypeMulticast,
205+
DefaultMulticastGroup: &defaultMulticastGroup,
202206
PIM: &evpnv1alpha1.FabricPIMSpec{
203207
AnycastRendezvousPoints: []evpnv1alpha1.AnycastRendezvousPoint{
204208
{
@@ -538,8 +542,7 @@ var _ = Describe("Fabric Controller", func() {
538542
g.Expect(nve.Spec.AnycastSourceInterfaceRef).NotTo(BeNil())
539543
g.Expect(nve.Spec.AnycastSourceInterfaceRef.Name).To(Equal(fabric.Name + "-" + leaf.Name + "-lo2"))
540544

541-
// L2 BUM mcast-group falls back to the PIM RP group when
542-
// spec.bum.defaultMulticastGroup is unset.
545+
// L2 BUM mcast-group is taken from spec.bum.defaultMulticastGroup.
543546
g.Expect(nve.Spec.MulticastGroups).NotTo(BeNil())
544547
g.Expect(nve.Spec.MulticastGroups.L2).NotTo(BeNil())
545548
g.Expect(nve.Spec.MulticastGroups.L2.String()).To(Equal("224.0.0.0/4"))
@@ -605,7 +608,8 @@ var _ = Describe("Fabric Controller", func() {
605608
},
606609
},
607610
BUM: evpnv1alpha1.FabricBUMSpec{
608-
Type: evpnv1alpha1.BUMTypeMulticast,
611+
Type: evpnv1alpha1.BUMTypeMulticast,
612+
DefaultMulticastGroup: &defaultMulticastGroup,
609613
PIM: &evpnv1alpha1.FabricPIMSpec{
610614
AnycastRendezvousPoints: []evpnv1alpha1.AnycastRendezvousPoint{{
611615
Name: "spine-rp",
@@ -845,7 +849,8 @@ var _ = Describe("Fabric Controller", func() {
845849
},
846850
},
847851
BUM: evpnv1alpha1.FabricBUMSpec{
848-
Type: evpnv1alpha1.BUMTypeMulticast,
852+
Type: evpnv1alpha1.BUMTypeMulticast,
853+
DefaultMulticastGroup: &defaultMulticastGroup,
849854
PIM: &evpnv1alpha1.FabricPIMSpec{
850855
AnycastRendezvousPoints: []evpnv1alpha1.AnycastRendezvousPoint{
851856
{
@@ -1053,7 +1058,8 @@ var _ = Describe("Fabric Controller", func() {
10531058
},
10541059
},
10551060
BUM: evpnv1alpha1.FabricBUMSpec{
1056-
Type: evpnv1alpha1.BUMTypeMulticast,
1061+
Type: evpnv1alpha1.BUMTypeMulticast,
1062+
DefaultMulticastGroup: &defaultMulticastGroup,
10571063
PIM: &evpnv1alpha1.FabricPIMSpec{
10581064
AnycastRendezvousPoints: []evpnv1alpha1.AnycastRendezvousPoint{
10591065
{
@@ -1126,37 +1132,3 @@ var _ = Describe("Fabric Controller", func() {
11261132
})
11271133
})
11281134
})
1129-
1130-
var _ = Describe("nveL2MulticastGroup", func() {
1131-
rpGroup := func(groups ...string) evpnv1alpha1.FabricPIMSpec {
1132-
prefixes := make([]corev1alpha1.IPPrefix, 0, len(groups))
1133-
for _, g := range groups {
1134-
prefixes = append(prefixes, corev1alpha1.MustParsePrefix(g))
1135-
}
1136-
return evpnv1alpha1.FabricPIMSpec{
1137-
AnycastRendezvousPoints: []evpnv1alpha1.AnycastRendezvousPoint{{Name: "rp", MulticastGroups: prefixes}},
1138-
}
1139-
}
1140-
1141-
It("returns the explicit defaultMulticastGroup when set", func() {
1142-
explicit := corev1alpha1.MustParsePrefix("239.0.0.1/32")
1143-
pim := rpGroup("224.0.0.0/4")
1144-
fabric := &evpnv1alpha1.Fabric{Spec: evpnv1alpha1.FabricSpec{BUM: evpnv1alpha1.FabricBUMSpec{
1145-
Type: evpnv1alpha1.BUMTypeMulticast, PIM: &pim, DefaultMulticastGroup: &explicit,
1146-
}}}
1147-
Expect(nveL2MulticastGroup(fabric)).To(Equal(&explicit))
1148-
})
1149-
1150-
It("falls back to the first RP multicastGroups entry when the field is unset", func() {
1151-
pim := rpGroup("224.0.0.0/4")
1152-
fabric := &evpnv1alpha1.Fabric{Spec: evpnv1alpha1.FabricSpec{BUM: evpnv1alpha1.FabricBUMSpec{
1153-
Type: evpnv1alpha1.BUMTypeMulticast, PIM: &pim,
1154-
}}}
1155-
Expect(nveL2MulticastGroup(fabric).String()).To(Equal("224.0.0.0/4"))
1156-
})
1157-
1158-
It("returns nil when BUM is not Multicast", func() {
1159-
fabric := &evpnv1alpha1.Fabric{Spec: evpnv1alpha1.FabricSpec{BUM: evpnv1alpha1.FabricBUMSpec{}}}
1160-
Expect(nveL2MulticastGroup(fabric)).To(BeNil())
1161-
})
1162-
})

0 commit comments

Comments
 (0)