Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prohibit usage of vni zero #105

Merged
merged 5 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/v1alpha1/layer2networkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Layer2NetworkConfigurationSpec struct {
MTU int `json:"mtu"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Minimum=1
This conversation was marked as resolved.
Show resolved Hide resolved
// VXLAN VNI Id for the layer 2 network
VNI int `json:"vni"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ spec:
x-kubernetes-map-type: atomic
vni:
description: VXLAN VNI Id for the layer 2 network
minimum: 1
This conversation was marked as resolved.
Show resolved Hide resolved
type: integer
vrf:
description: VRF to attach Layer2 network to, default if not set
Expand Down
6 changes: 6 additions & 0 deletions pkg/reconciler/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ func (r *reconcile) createVrfConfigMap(l3vnis []networkv1alpha1.VRFRouteConfigur
continue
}

if vni == 0 {
This conversation was marked as resolved.
Show resolved Hide resolved
err := fmt.Errorf("VNI can not be set to 0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add the upper boundary in the error message

r.Logger.Error(err, "VNI can not be set to 0, ignoring", "vrf", spec.VRF, "name", l3vnis[i].ObjectMeta.Name, "namespace", l3vnis[i].ObjectMeta.Namespace)
continue
}

cfg, err := createVrfConfig(vrfConfigMap, &spec, vni, rt)
if err != nil {
return nil, err
Expand Down