Skip to content

api: support buffer limit in clientTrafficPolicy#2805

Merged
arkodg merged 28 commits intoenvoyproxy:mainfrom
yaelSchechter:buffer-limit-api
Mar 29, 2024
Merged

api: support buffer limit in clientTrafficPolicy#2805
arkodg merged 28 commits intoenvoyproxy:mainfrom
yaelSchechter:buffer-limit-api

Conversation

@yaelSchechter
Copy link
Copy Markdown
Contributor

@yaelSchechter yaelSchechter commented Mar 6, 2024

What this PR does / why we need it:

This PR introduces configurability for the per_connection_buffer_limit_bytes parameter. It uses the struct proposed in this PR: #2709, pending its merge.

Which issue(s) this PR fixes:

Fixes #2600

Signed-off-by: Yael Shechter <yael.shechter@sap.com>
@yaelSchechter yaelSchechter requested a review from a team as a code owner March 6, 2024 15:51
yaelSchechter and others added 2 commits March 7, 2024 08:21
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.50%. Comparing base (3d51933) to head (1326cb4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2805   +/-   ##
=======================================
  Coverage   64.50%   64.50%           
=======================================
  Files         121      121           
  Lines       21397    21397           
=======================================
  Hits        13803    13803           
  Misses       6723     6723           
  Partials      871      871           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zirain zirain added this to the Backlog milestone Mar 7, 2024
yaelSchechter and others added 5 commits March 20, 2024 18:30
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
yaelSchechter and others added 5 commits March 26, 2024 13:45
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Signed-off-by: Yael Shechter <yael.shechter@sap.com>
// +optional
ConnectionLimit *ConnectionLimit `json:"connectionLimit,omitempty"`
// BufferLimit provides configuration for the maximum buffer size for each incoming connection.
// For example, 128Mi, 500m, 2G, etc.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the type accepts a lot more such as 500m is not relevant for this field.
can we limit it to specific types relevant for memory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean, limit the use for only binary suffixes (Ki | Mi | Gi | Ti | Pi | Ei) and not decimal suffixed? (m | "" | k | M | G | T | P | E)
If so, I can change the example and limit it using the kubebuilder schema validation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe *uint32 is a better option after all, validating the *resource.Quantity might be a bit complex (unnecessarily) :)
Changed to *uint32.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw I did like the fact that the abstracted type was handling known quantities very well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about runtime validation instead? users will get an error on the CTP but it won't prevent them from applying a resource with cpu specific suffixes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, so the outlining the goal

  • as a user, i'd like to specify mem in terms on absolute value (bytes), or known quantities (K, M, G, Ki, Mi, Gi)

Options

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed back to Quantity and added a cel validation. It will check that the suffix, if present, is compatible with the suffixes for memory: units of memory in k8s.

One more thing, values without suffix, like 1500 (bytes) must be specified with "" (otherwise there is an error). Is it something known to users as k8s behavior, or should I document it as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate on "" , that feels like something that might annoy the user :)
thoughts on the string approach with kubebuilder validations, and then typecasting into resource.Quantity so the user doesnt hit the gotcha ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lior's suggestion solved the problem 👍

// Note that when the suffix is not provided, the value is interpreted as bytes.
// Default: 32768 bytes.
//
// +kubebuilder:validation:XValidation:rule="self.matches(r\"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\")",message="bufferLimit must be of the format \"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$\""
Copy link
Copy Markdown
Contributor

@liorokman liorokman Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest changing the CEL rule to:

type(self) == string ? self.matches(r"^[1-9]+[0-9]*([EPTGMK]i|[EPTGMk])?$") : type(self) == int

This way it works for raw numbers as well as for string values.

CEL playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that did the trick

Signed-off-by: Yael Shechter <yael.shechter@sap.com>
Copy link
Copy Markdown
Contributor

@guydc guydc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a knob to make per_connection_buffer_limit_bytes configurable

6 participants