diff --git a/api/v1alpha1/fault_injection.go b/api/v1alpha1/fault_injection.go index eab92714c5..3a91b7c3a5 100644 --- a/api/v1alpha1/fault_injection.go +++ b/api/v1alpha1/fault_injection.go @@ -53,6 +53,8 @@ type FaultInjectionAbort struct { // GrpcStatus specifies the GRPC status code to be returned // // +optional + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=16 GrpcStatus *int32 `json:"grpcStatus,omitempty"` // Percentage specifies the percentage of requests to be aborted. Default 100%, if set 0, no requests will be aborted. Accuracy to 0.0001%. diff --git a/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml index 856f8d8522..1f35b5da3e 100644 --- a/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml +++ b/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml @@ -349,6 +349,8 @@ spec: description: GrpcStatus specifies the GRPC status code to be returned format: int32 + maximum: 16 + minimum: 0 type: integer httpStatus: description: StatusCode specifies the HTTP status code to diff --git a/charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml index aa12901fec..555021709e 100644 --- a/charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml +++ b/charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml @@ -348,6 +348,8 @@ spec: description: GrpcStatus specifies the GRPC status code to be returned format: int32 + maximum: 16 + minimum: 0 type: integer httpStatus: description: StatusCode specifies the HTTP status code to diff --git a/internal/gatewayapi/backendtrafficpolicy.go b/internal/gatewayapi/backendtrafficpolicy.go index ef5b9086b7..036b9de0ef 100644 --- a/internal/gatewayapi/backendtrafficpolicy.go +++ b/internal/gatewayapi/backendtrafficpolicy.go @@ -1695,7 +1695,7 @@ func (t *Translator) buildFaultInjection(policy *egv1a1.BackendTrafficPolicy) *i } if policy.Spec.FaultInjection.Abort.GrpcStatus != nil { - fi.Abort.GrpcStatus = policy.Spec.FaultInjection.Abort.GrpcStatus + fi.Abort.GrpcStatus = new(uint32(*policy.Spec.FaultInjection.Abort.GrpcStatus)) } if policy.Spec.FaultInjection.Abort.HTTPStatus != nil { fi.Abort.HTTPStatus = policy.Spec.FaultInjection.Abort.HTTPStatus diff --git a/internal/ir/xds.go b/internal/ir/xds.go index 6e54220d4b..ca4c1aba64 100644 --- a/internal/ir/xds.go +++ b/internal/ir/xds.go @@ -1655,7 +1655,7 @@ type FaultInjectionAbort struct { // HTTPStatus defines the HTTP status code to be returned. HTTPStatus *int32 `json:"httpStatus,omitempty" yaml:"httpStatus,omitempty"` // GrpcStatus defines the gRPC status code to be returned. - GrpcStatus *int32 `json:"grpcStatus,omitempty" yaml:"grpcStatus,omitempty"` + GrpcStatus *uint32 `json:"grpcStatus,omitempty" yaml:"grpcStatus,omitempty"` // Percentage defines the percentage of requests to be aborted. Percentage *float32 `json:"percentage,omitempty" yaml:"percentage,omitempty"` } diff --git a/internal/ir/zz_generated.deepcopy.go b/internal/ir/zz_generated.deepcopy.go index 5b47d06ccb..811b7791d6 100644 --- a/internal/ir/zz_generated.deepcopy.go +++ b/internal/ir/zz_generated.deepcopy.go @@ -1622,7 +1622,7 @@ func (in *FaultInjectionAbort) DeepCopyInto(out *FaultInjectionAbort) { } if in.GrpcStatus != nil { in, out := &in.GrpcStatus, &out.GrpcStatus - *out = new(int32) + *out = new(uint32) **out = **in } if in.Percentage != nil { diff --git a/internal/xds/translator/fault.go b/internal/xds/translator/fault.go index e017d00395..142fd58ea1 100644 --- a/internal/xds/translator/fault.go +++ b/internal/xds/translator/fault.go @@ -152,7 +152,7 @@ func (*fault) patchRoute(route *routev3.Route, irRoute *ir.HTTPRoute, _ *ir.HTTP } if abort.GrpcStatus != nil { routeCfgProto.Abort.ErrorType = &xdshttpfaultv3.FaultAbort_GrpcStatus{ - GrpcStatus: uint32(*abort.GrpcStatus), + GrpcStatus: *abort.GrpcStatus, } } } diff --git a/test/helm/gateway-crds-helm/all.out.yaml b/test/helm/gateway-crds-helm/all.out.yaml index 3c3e2be7b4..517cc0d38c 100644 --- a/test/helm/gateway-crds-helm/all.out.yaml +++ b/test/helm/gateway-crds-helm/all.out.yaml @@ -22876,6 +22876,8 @@ spec: description: GrpcStatus specifies the GRPC status code to be returned format: int32 + maximum: 16 + minimum: 0 type: integer httpStatus: description: StatusCode specifies the HTTP status code to diff --git a/test/helm/gateway-crds-helm/e2e.out.yaml b/test/helm/gateway-crds-helm/e2e.out.yaml index 5077a7985f..30f04545d2 100644 --- a/test/helm/gateway-crds-helm/e2e.out.yaml +++ b/test/helm/gateway-crds-helm/e2e.out.yaml @@ -849,6 +849,8 @@ spec: description: GrpcStatus specifies the GRPC status code to be returned format: int32 + maximum: 16 + minimum: 0 type: integer httpStatus: description: StatusCode specifies the HTTP status code to diff --git a/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml b/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml index bffc9b1497..e0fdfc5155 100644 --- a/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml +++ b/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml @@ -849,6 +849,8 @@ spec: description: GrpcStatus specifies the GRPC status code to be returned format: int32 + maximum: 16 + minimum: 0 type: integer httpStatus: description: StatusCode specifies the HTTP status code to