diff --git a/pkg/util/validator.go b/pkg/util/validator.go index 550493984ca7..d92986901a4b 100644 --- a/pkg/util/validator.go +++ b/pkg/util/validator.go @@ -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 { diff --git a/pkg/util/validator_test.go b/pkg/util/validator_test.go index 8f37442ce134..164dc7131f99 100644 --- a/pkg/util/validator_test.go +++ b/pkg/util/validator_test.go @@ -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", @@ -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", @@ -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 { diff --git a/pkg/webhook/subnet.go b/pkg/webhook/subnet.go index 1f571d7aa625..91d505db6318 100644 --- a/pkg/webhook/subnet.go +++ b/pkg/webhook/subnet.go @@ -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{} @@ -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")