Skip to content

Commit

Permalink
check if subnet cidr is correct (#2136)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Dec 7, 2022
1 parent f58c88f commit 2156ef0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/util/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func ValidateSubnet(subnet kubeovnv1.Subnet) error {
}
}

for _, cidr := range strings.Split(subnet.Spec.CIDRBlock, ",") {
if _, _, err := net.ParseCIDR(cidr); err != nil {
return fmt.Errorf("subnet %s cidr %s is invalid", subnet.Name, cidr)
}
}

allow := subnet.Spec.AllowSubnets
for _, cidr := range allow {
if _, _, err := net.ParseCIDR(cidr); err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func NewValidatingHook(c cache.Cache) (*ValidatingHook, error) {
updateHooks[subnetGVK] = v.SubnetUpdateHook

deleteHooks[subnetGVK] = v.SubnetDeleteHook

deleteHooks[vpcGVK] = v.VpcDeleteHook

return v, nil
Expand Down
2 changes: 1 addition & 1 deletion yamls/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
hostNetwork: true
containers:
- name: kube-ovn-webhook
image: "kubeovn/kube-ovn:v1.10.0"
image: "kubeovn/kube-ovn:v1.11.0"
imagePullPolicy: IfNotPresent
command:
- /kube-ovn/kube-ovn-webhook
Expand Down

0 comments on commit 2156ef0

Please sign in to comment.