Skip to content

Commit 00d0895

Browse files
authored
api: add cel validation of MaxEjectionPercent (#8804)
add cel validation of MaxEjectionPercent Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
1 parent a056d44 commit 00d0895

18 files changed

Lines changed: 115 additions & 10 deletions

api/v1alpha1/healthcheck_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ type PassiveHealthCheck struct {
7070
// MaxEjectionPercent sets the maximum percentage of hosts in a cluster that can be ejected.
7171
//
7272
// +kubebuilder:default=10
73+
// +kubebuilder:validation:Minimum=0
74+
// +kubebuilder:validation:Maximum=100
7375
// +optional
7476
MaxEjectionPercent *int32 `json:"maxEjectionPercent,omitempty"`
7577

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ spec:
698698
description: MaxEjectionPercent sets the maximum percentage
699699
of hosts in a cluster that can be ejected.
700700
format: int32
701+
maximum: 100
702+
minimum: 0
701703
type: integer
702704
splitExternalLocalOriginErrors:
703705
default: false

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ spec:
807807
description: MaxEjectionPercent sets the maximum
808808
percentage of hosts in a cluster that can be ejected.
809809
format: int32
810+
maximum: 100
811+
minimum: 0
810812
type: integer
811813
splitExternalLocalOriginErrors:
812814
default: false

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_envoyproxies.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12100,6 +12100,8 @@ spec:
1210012100
of hosts in a cluster that can
1210112101
be ejected.
1210212102
format: int32
12103+
maximum: 100
12104+
minimum: 0
1210312105
type: integer
1210412106
splitExternalLocalOriginErrors:
1210512107
default: false
@@ -13624,6 +13626,8 @@ spec:
1362413626
of hosts in a cluster that can
1362513627
be ejected.
1362613628
format: int32
13629+
maximum: 100
13630+
minimum: 0
1362713631
type: integer
1362813632
splitExternalLocalOriginErrors:
1362913633
default: false
@@ -15320,6 +15324,8 @@ spec:
1532015324
the maximum percentage of hosts in
1532115325
a cluster that can be ejected.
1532215326
format: int32
15327+
maximum: 100
15328+
minimum: 0
1532315329
type: integer
1532415330
splitExternalLocalOriginErrors:
1532515331
default: false
@@ -16921,6 +16927,8 @@ spec:
1692116927
percentage of hosts in a cluster that can
1692216928
be ejected.
1692316929
format: int32
16930+
maximum: 100
16931+
minimum: 0
1692416932
type: integer
1692516933
splitExternalLocalOriginErrors:
1692616934
default: false

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_securitypolicies.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,8 @@ spec:
14381438
percentage of hosts in a cluster that can be
14391439
ejected.
14401440
format: int32
1441+
maximum: 100
1442+
minimum: 0
14411443
type: integer
14421444
splitExternalLocalOriginErrors:
14431445
default: false
@@ -2834,6 +2836,8 @@ spec:
28342836
percentage of hosts in a cluster that can be
28352837
ejected.
28362838
format: int32
2839+
maximum: 100
2840+
minimum: 0
28372841
type: integer
28382842
splitExternalLocalOriginErrors:
28392843
default: false
@@ -4507,6 +4511,8 @@ spec:
45074511
maximum percentage of hosts in a cluster
45084512
that can be ejected.
45094513
format: int32
4514+
maximum: 100
4515+
minimum: 0
45104516
type: integer
45114517
splitExternalLocalOriginErrors:
45124518
default: false
@@ -6203,6 +6209,8 @@ spec:
62036209
percentage of hosts in a cluster that can be
62046210
ejected.
62056211
format: int32
6212+
maximum: 100
6213+
minimum: 0
62066214
type: integer
62076215
splitExternalLocalOriginErrors:
62086216
default: false

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ spec:
697697
description: MaxEjectionPercent sets the maximum percentage
698698
of hosts in a cluster that can be ejected.
699699
format: int32
700+
maximum: 100
701+
minimum: 0
700702
type: integer
701703
splitExternalLocalOriginErrors:
702704
default: false

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ spec:
806806
description: MaxEjectionPercent sets the maximum
807807
percentage of hosts in a cluster that can be ejected.
808808
format: int32
809+
maximum: 100
810+
minimum: 0
809811
type: integer
810812
splitExternalLocalOriginErrors:
811813
default: false

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_envoyproxies.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12099,6 +12099,8 @@ spec:
1209912099
of hosts in a cluster that can
1210012100
be ejected.
1210112101
format: int32
12102+
maximum: 100
12103+
minimum: 0
1210212104
type: integer
1210312105
splitExternalLocalOriginErrors:
1210412106
default: false
@@ -13623,6 +13625,8 @@ spec:
1362313625
of hosts in a cluster that can
1362413626
be ejected.
1362513627
format: int32
13628+
maximum: 100
13629+
minimum: 0
1362613630
type: integer
1362713631
splitExternalLocalOriginErrors:
1362813632
default: false
@@ -15319,6 +15323,8 @@ spec:
1531915323
the maximum percentage of hosts in
1532015324
a cluster that can be ejected.
1532115325
format: int32
15326+
maximum: 100
15327+
minimum: 0
1532215328
type: integer
1532315329
splitExternalLocalOriginErrors:
1532415330
default: false
@@ -16920,6 +16926,8 @@ spec:
1692016926
percentage of hosts in a cluster that can
1692116927
be ejected.
1692216928
format: int32
16929+
maximum: 100
16930+
minimum: 0
1692316931
type: integer
1692416932
splitExternalLocalOriginErrors:
1692516933
default: false

charts/gateway-helm/charts/crds/crds/generated/gateway.envoyproxy.io_securitypolicies.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,8 @@ spec:
14371437
percentage of hosts in a cluster that can be
14381438
ejected.
14391439
format: int32
1440+
maximum: 100
1441+
minimum: 0
14401442
type: integer
14411443
splitExternalLocalOriginErrors:
14421444
default: false
@@ -2833,6 +2835,8 @@ spec:
28332835
percentage of hosts in a cluster that can be
28342836
ejected.
28352837
format: int32
2838+
maximum: 100
2839+
minimum: 0
28362840
type: integer
28372841
splitExternalLocalOriginErrors:
28382842
default: false
@@ -4506,6 +4510,8 @@ spec:
45064510
maximum percentage of hosts in a cluster
45074511
that can be ejected.
45084512
format: int32
4513+
maximum: 100
4514+
minimum: 0
45094515
type: integer
45104516
splitExternalLocalOriginErrors:
45114517
default: false
@@ -6202,6 +6208,8 @@ spec:
62026208
percentage of hosts in a cluster that can be
62036209
ejected.
62046210
format: int32
6211+
maximum: 100
6212+
minimum: 0
62056213
type: integer
62066214
splitExternalLocalOriginErrors:
62076215
default: false

internal/gatewayapi/backendtrafficpolicy_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func TestBuildPassiveHealthCheck(t *testing.T) {
272272
expected: &ir.OutlierDetection{
273273
Interval: ir.MetaV1DurationPtr(10 * time.Second),
274274
BaseEjectionTime: ir.MetaV1DurationPtr(30 * time.Second),
275-
MaxEjectionPercent: new(int32(10)),
275+
MaxEjectionPercent: new(uint32(10)),
276276
Consecutive5xxErrors: new(uint32(5)),
277277
},
278278
},
@@ -290,7 +290,7 @@ func TestBuildPassiveHealthCheck(t *testing.T) {
290290
expected: &ir.OutlierDetection{
291291
Interval: ir.MetaV1DurationPtr(10 * time.Second),
292292
BaseEjectionTime: ir.MetaV1DurationPtr(30 * time.Second),
293-
MaxEjectionPercent: new(int32(10)),
293+
MaxEjectionPercent: new(uint32(10)),
294294
Consecutive5xxErrors: new(uint32(5)),
295295
FailurePercentageThreshold: new(uint32(90)),
296296
},
@@ -317,7 +317,7 @@ func TestBuildPassiveHealthCheck(t *testing.T) {
317317
ConsecutiveGatewayErrors: new(uint32(2)),
318318
Consecutive5xxErrors: new(uint32(5)),
319319
BaseEjectionTime: ir.MetaV1DurationPtr(30 * time.Second),
320-
MaxEjectionPercent: new(int32(10)),
320+
MaxEjectionPercent: new(uint32(10)),
321321
FailurePercentageThreshold: new(uint32(85)),
322322
AlwaysEjectOneEndpoint: new(true),
323323
},

0 commit comments

Comments
 (0)