-
Notifications
You must be signed in to change notification settings - Fork 33
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
Enhance creation of RateLimitPolicy around missing limits. #1024
Conversation
Ensure the user can create a ratelimit policy without at least one limit. Signed-off-by: Jim Fitzpatrick <jfitzpat@redhat.com>
388af1f
to
c11c535
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I miss a integration test (with actual k8s running) in tests/common/ratelimitpolicy/ratelimitpolicy_controller_test.go
for the following use cases:
- no defaults, no overrides, no limits -> client return error on create
- with defaults, no limits -> client return error on create
- with overrides, no limits -> client return error on create
I can add some test no problem. |
Add integration tests for the six states that the user can try add invaild limit blocks. This does not check if the limits are valid only that they are there. Signed-off-by: Jim Fitzpatrick <jfitzpat@redhat.com>
4678c23
to
dea4490
Compare
api/v1/ratelimitpolicy_types.go
Outdated
@@ -153,6 +153,9 @@ func (p *RateLimitPolicy) Kind() string { | |||
// +kubebuilder:validation:XValidation:rule="!(has(self.defaults) && has(self.limits))",message="Implicit and explicit defaults are mutually exclusive" | |||
// +kubebuilder:validation:XValidation:rule="!(has(self.defaults) && has(self.overrides))",message="Overrides and explicit defaults are mutually exclusive" | |||
// +kubebuilder:validation:XValidation:rule="!(has(self.overrides) && has(self.limits))",message="Overrides and implicit defaults are mutually exclusive" | |||
// +kubebuilder:validation:XValidation:rule="!(has(self.overrides) || has(self.defaults)) ? has(self.limits) && size(self.limits) > 0 : true",message="At least one spec.limits most be defined" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**most** be defined
👀
777ebfc
to
4eabb56
Compare
Signed-off-by: Jim Fitzpatrick <jfitzpat@redhat.com>
4eabb56
to
d79a7d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 👍
Ensure the user can create a ratelimit policy without at least one limit.
closes: #1023
Validate
Try apply the following policies to the installation. They should both fail with different failure messages. Any policy where the name is
toystore-*1
should be applied to the cluster.