Skip to content

Commit 45ab52e

Browse files
Add API for GEP-3171 (#3283)
* Create index.md * Create metadata.yaml * Update index.md * Update metadata.yaml * Remove 'omitempty' from Fraction fields * Split MirrorPercent into two fields: MirrorPercent and MirrorFraction. * Update index.md * Add config examples. * Add Existing Support Table * Update field names to avoid 'stuttering' in names. * Update geps/gep-3171/index.md Co-authored-by: Rob Scott <[email protected]> * Add Fraction type * Add percent and fraction to HTTPRequestMirrorFilter * Update apis/v1/httproute_types.go Co-authored-by: Rob Scott <[email protected]> * Update apis/v1/shared_types.go Co-authored-by: Rob Scott <[email protected]> * Add CEL validation to Fraction type * Add CEL validation to HttpRequestMirrorFilter Also updated field descriptions to match the validation. Removed the default value for Percent. * Add CEL validation test for HTTPRequestMirrorFilter * Ran /hack/update-codegen.sh * Update httproute_experimental_test.go * Update httproute_experimental_test.go * Update httproute_experimental_test.go * Update httproute_types.go * Reran /hack/update-codegen.sh * Update httproute_experimental_test.go * Make Denominator field a pointer to distinguish between 0 and unset Co-authored-by: Rob Scott <[email protected]> * Change Percent to be a pointer to distinguish between 0 and unset Co-authored-by: Rob Scott <[email protected]> * Update httproute_experimental_test.go * Update httproute_experimental_test.go * Format httproute_types.go * Make Fraction a pointer * Update httproute_experimental_test.go * Reran hack/update-codegen.sh * Updating to test CEL validation * Updating to test CEL validation * Update httproute_types.go * Update httproute_experimental_test.go * Update httproute_experimental_test.go * Update httproute_experimental_test.go * Update httproute_types.go * Update httproute_experimental_test.go * Update httproute_types.go * Update httproute_types.go * testing * Update httproute_types.go * Ran hack/update-codegen.sh * format shared_types.go * Update httproute_types.go * Update httproute_experimental_test.go * Update httproute_types.go * Update httproute_types.go * reran hack/update-codegen.sh * Update httproute_types.go * Update httproute_experimental_test.go * Reran hack/update-codegen.sh * Added RequestMirror validation to GRPCRoute * Create grcproute_experimental_test.go * Update grcproute_experimental_test.go * Update grpcroute_types.go * Update grcproute_experimental_test.go * Ran hack/update-codegen.sh * Update grcproute_experimental_test.go * Update grcproute_experimental_test.go * Update Copyright Year * Update pkg/test/cel/grcproute_experimental_test.go Co-authored-by: Rob Scott <[email protected]> * Update httproute_experimental_test.go * Update grcproute_experimental_test.go --------- Co-authored-by: Rob Scott <[email protected]>
1 parent 689c1cf commit 45ab52e

15 files changed

+744
-19
lines changed

apis/applyconfiguration/apis/v1/fraction.go

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/applyconfiguration/apis/v1/httprequestmirrorfilter.go

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/applyconfiguration/internal/internal.go

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/applyconfiguration/utils.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1/grpcroute_types.go

+2
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ type GRPCRouteFilter struct {
550550
// Support: Extended
551551
//
552552
// +optional
553+
//
554+
// <gateway:experimental:validation:XValidation:message="Only one of percent or fraction may be specified in HTTPRequestMirrorFilter",rule="!(has(self.percent) && has(self.fraction))">
553555
RequestMirror *HTTPRequestMirrorFilter `json:"requestMirror,omitempty"`
554556

555557
// ExtensionRef is an optional, implementation-specific extension to the

apis/v1/httproute_types.go

+25
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ type HTTPRouteFilter struct {
757757
// Support: Extended
758758
//
759759
// +optional
760+
//
761+
// <gateway:experimental:validation:XValidation:message="Only one of percent or fraction may be specified in HTTPRequestMirrorFilter",rule="!(has(self.percent) && has(self.fraction))">
760762
RequestMirror *HTTPRequestMirrorFilter `json:"requestMirror,omitempty"`
761763

762764
// RequestRedirect defines a schema for a filter that responds to the
@@ -1153,6 +1155,29 @@ type HTTPRequestMirrorFilter struct {
11531155
//
11541156
// Support: Implementation-specific for any other resource
11551157
BackendRef BackendObjectReference `json:"backendRef"`
1158+
1159+
// Percent represents the percentage of requests that should be
1160+
// mirrored to BackendRef. Its minimum value is 0 (indicating 0% of
1161+
// requests) and its maximum value is 100 (indicating 100% of requests).
1162+
//
1163+
// Only one of Fraction or Percent may be specified. If neither field
1164+
// is specified, 100% of requests will be mirrored.
1165+
//
1166+
// +optional
1167+
// +kubebuilder:validation:Minimum=0
1168+
// +kubebuilder:validation:Maximum=100
1169+
// <gateway:experimental>
1170+
Percent *int32 `json:"percent,omitempty"`
1171+
1172+
// Fraction represents the fraction of requests that should be
1173+
// mirrored to BackendRef.
1174+
//
1175+
// Only one of Fraction or Percent may be specified. If neither field
1176+
// is specified, 100% of requests will be mirrored.
1177+
//
1178+
// +optional
1179+
// <gateway:experimental>
1180+
Fraction Fraction `json:"fraction,omitempty"`
11561181
}
11571182

11581183
// HTTPBackendRef defines how a HTTPRoute forwards a HTTP request.

apis/v1/shared_types.go

+11
Original file line numberDiff line numberDiff line change
@@ -855,3 +855,14 @@ const (
855855
// Support: Extended
856856
PermanentCookieLifetimeType CookieLifetimeType = "Permanent"
857857
)
858+
859+
// +kubebuilder:validation:XValidation:message="numerator must be less than or equal to denominator",rule="self.numerator <= self.denominator"
860+
type Fraction struct {
861+
// +kubebuilder:validation:Minimum=0
862+
Numerator int32 `json:"numerator"`
863+
864+
// +optional
865+
// +kubebuilder:default=100
866+
// +kubebuilder:validation:Minimum=1
867+
Denominator *int32 `json:"denominator,omitempty"`
868+
}

apis/v1/zz_generated.deepcopy.go

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)