Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: support buffer limit in clientTrafficPolicy #2805

Merged
merged 28 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cafad23
api: support buffer limit in clientTrafficPolicy
yaelSchechter Mar 6, 2024
b1deee3
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 7, 2024
26d992d
run make commands
yaelSchechter Mar 7, 2024
4f6c2da
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 7, 2024
b6b1763
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 10, 2024
e3e46c8
resolve conflicts
yaelSchechter Mar 18, 2024
874d24f
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 19, 2024
dd6b526
run gen-check
yaelSchechter Mar 19, 2024
f303cc0
Merge branch 'buffer-limit-api' of https://github.com/yaelSchechter/e…
yaelSchechter Mar 19, 2024
8339fa6
Merge branch 'main' of https://github.com/yaelSchechter/envoy-gateway…
yaelSchechter Mar 20, 2024
847ee5d
fix cr comment
yaelSchechter Mar 21, 2024
21a8c9c
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 21, 2024
b86fd68
add default
yaelSchechter Mar 21, 2024
f9755cb
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 21, 2024
83e8cbf
resolve conflicts
yaelSchechter Mar 26, 2024
6c90143
resolve conflicts
yaelSchechter Mar 26, 2024
1b679b0
resolve conflicts
yaelSchechter Mar 26, 2024
99ba4d4
add examples
yaelSchechter Mar 26, 2024
ebb0a4e
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 26, 2024
9112b6a
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 26, 2024
93ae109
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 27, 2024
249fac4
use uint32 for buffer limit
yaelSchechter Mar 27, 2024
59ce260
Merge branch 'main' of https://github.com/yaelSchechter/envoy-gateway…
yaelSchechter Mar 27, 2024
ea9696c
Merge branch 'buffer-limit-api' of https://github.com/yaelSchechter/e…
yaelSchechter Mar 27, 2024
1eaf88f
use quantity and add a schema validation
yaelSchechter Mar 28, 2024
abf1f36
Merge branch 'main' into buffer-limit-api
yaelSchechter Mar 28, 2024
3706559
add a type check
yaelSchechter Mar 28, 2024
1326cb4
Merge branch 'buffer-limit-api' of https://github.com/yaelSchechter/e…
yaelSchechter Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion api/v1alpha1/connection_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
import (
"k8s.io/apimachinery/pkg/api/resource"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// Connection allows users to configure connection-level settings
type Connection struct {
// ConnectionLimit defines limits related to connections
//
// +optional
ConnectionLimit *ConnectionLimit `json:"connectionLimit,omitempty"`
// BufferLimit provides configuration for the maximum buffer size in bytes for each incoming connection.
// For example, 20Mi, 1Gi, 256Ki etc.
// Note that when the suffix is not provided, the value is interpreted as bytes.
// Default: 32768 bytes.
//
// +kubebuilder:validation:XValidation:rule="type(self) == string ? self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\") : type(self) == int",message="bufferLimit must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\""
// +optional
BufferLimit *resource.Quantity `json:"bufferLimit,omitempty"`
zirain marked this conversation as resolved.
Show resolved Hide resolved
}

type ConnectionLimit struct {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ spec:
connection:
description: Connection includes client connection settings.
properties:
bufferLimit:
anyOf:
- type: integer
- type: string
description: 'BufferLimit provides configuration for the maximum
buffer size in bytes for each incoming connection. For example,
20Mi, 1Gi, 256Ki etc. Note that when the suffix is not provided,
the value is interpreted as bytes. Default: 32768 bytes.'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
x-kubernetes-validations:
- message: bufferLimit must be of the format "^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$"
rule: 'type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$")
: type(self) == int'
connectionLimit:
description: ConnectionLimit defines limits related to connections
properties:
Expand Down
1 change: 1 addition & 0 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ _Appears in:_
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `connectionLimit` | _[ConnectionLimit](#connectionlimit)_ | false | ConnectionLimit defines limits related to connections |
| `bufferLimit` | _[Quantity](#quantity)_ | false | BufferLimit provides configuration for the maximum buffer size in bytes for each incoming connection. For example, 20Mi, 1Gi, 256Ki etc. Note that when the suffix is not provided, the value is interpreted as bytes. Default: 32768 bytes. |


#### ConnectionLimit
Expand Down
21 changes: 21 additions & 0 deletions test/cel-validation/clienttrafficpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package celvalidation
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/api/resource"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -263,6 +264,26 @@ func TestClientTrafficPolicyTarget(t *testing.T) {
},
wantErrors: []string{},
},
{
desc: "invalid bufferLimit format",
mutate: func(ctp *egv1a1.ClientTrafficPolicy) {
ctp.Spec = egv1a1.ClientTrafficPolicySpec{
TargetRef: gwapiv1a2.PolicyTargetReferenceWithSectionName{
PolicyTargetReference: gwapiv1a2.PolicyTargetReference{
Group: gwapiv1a2.Group("gateway.networking.k8s.io"),
Kind: gwapiv1a2.Kind("Gateway"),
Name: gwapiv1a2.ObjectName("eg"),
},
},
Connection: &egv1a1.Connection{
BufferLimit: ptr.To(resource.MustParse("15m")),
},
}
},
wantErrors: []string{
"spec.connection.bufferLimit: Invalid value: \"\": bufferLimit must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\"",
},
},
}

for _, tc := range cases {
Expand Down
Loading