Skip to content

Commit

Permalink
fix 409 (#3662)
Browse files Browse the repository at this point in the history
Signed-off-by: bobz965 <[email protected]>
  • Loading branch information
bobz965 committed Jan 23, 2024
1 parent b2f7da5 commit 0da94b5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/util/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func ValidateSubnet(subnet kubeovnv1.Subnet) error {

if len(ips) == 1 {
if net.ParseIP(ips[0]) == nil {
return fmt.Errorf("ip %s in exclude_ips is not a valid address", ips[0])
return fmt.Errorf("ip %s in excludeIps is not a valid address", ips[0])
}
}

if len(ips) == 2 {
for _, ip := range ips {
if net.ParseIP(ip) == nil {
return fmt.Errorf("ip %s in exclude_ips is not a valid address", ip)
return fmt.Errorf("ip %s in excludeIps is not a valid address", ip)
}
}
if IP2BigInt(ips[0]).Cmp(IP2BigInt(ips[1])) == 1 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestValidateSubnet(t *testing.T) {
},
Status: kubeovnv1.SubnetStatus{},
},
err: "exclude_ips is not a valid address",
err: "excludeIps is not a valid address",
},
{
name: "ExcludeIPNotIPErr",
Expand All @@ -222,7 +222,7 @@ func TestValidateSubnet(t *testing.T) {
},
Status: kubeovnv1.SubnetStatus{},
},
err: "in exclude_ips is not a valid address",
err: "in excludeIps is not a valid address",
},
{
name: "ExcludeIPRangeErr",
Expand Down Expand Up @@ -474,7 +474,7 @@ func TestValidateSubnet(t *testing.T) {
},
Status: kubeovnv1.SubnetStatus{},
},
err: "ip 10.16.1 in exclude_ips is not a valid address",
err: "ip 10.16.1 in excludeIps is not a valid address",
},
}
for _, tt := range tests {
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhook/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (v *ValidatingHook) SubnetCreateHook(ctx context.Context, req admission.Req
return ctrlwebhook.Errored(http.StatusBadRequest, err)
}
if err := util.ValidateCidrConflict(o, subnetList.Items); err != nil {
return ctrlwebhook.Denied(err.Error())
return admission.Errored(http.StatusConflict, err)
}

vpcList := &ovnv1.VpcList{}
Expand Down Expand Up @@ -77,7 +77,7 @@ func (v *ValidatingHook) SubnetUpdateHook(ctx context.Context, req admission.Req
return ctrlwebhook.Errored(http.StatusBadRequest, err)
}
if err := util.ValidateCidrConflict(o, subnetList.Items); err != nil {
return ctrlwebhook.Denied(err.Error())
return admission.Errored(http.StatusConflict, err)
}

return ctrlwebhook.Allowed("by pass")
Expand Down

0 comments on commit 0da94b5

Please sign in to comment.