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

Add validation rule for 'noRetry' parameter in ProvisioningRequestSpec #7547

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

omerap12
Copy link
Member

@omerap12 omerap12 commented Dec 1, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds parameter validation for check-capacity.autoscaling.x-k8s.io provisioning class to validate that only the 'noRetry' parameter is allowed with values 'true' or 'false'. This helps users by providing immediate feedback when invalid parameters are used rather than discovering issues at runtime.

Which issue(s) this PR fixes:

Fixes #7511

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Users will get validation errors when using invalid parameters with check-capacity.autoscaling.x-k8s.io provisioning class. Only 'noRetry' parameter is allowed with values 'true' or 'false'. 

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 1, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: omerap12
Once this PR has been reviewed and has the lgtm label, please assign bigdarkclown for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 1, 2024
@PBundyra
Copy link
Contributor

PBundyra commented Dec 2, 2024

/cc @aleksandra-malinowska

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2024
Signed-off-by: Omer Aplatony <[email protected]>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2024
@omerap12
Copy link
Member Author

omerap12 commented Dec 6, 2024

friendly ping :) @PBundyra

Signed-off-by: Omer Aplatony <[email protected]>
@PBundyra
Copy link
Contributor

PBundyra commented Dec 6, 2024

friendly ping :) @PBundyra

It lgtm but I don't have approvers rights

@@ -113,6 +113,7 @@ type ProvisioningRequestSpec struct {
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// +kubebuilder:validation:MaxProperties=100
// +kubebuilder:validation:XValidation:rule="self.all(k, v, if parent.provisioningClassName == 'check-capacity.autoscaling.x-k8s.io' then k == 'noRetry' && v in ['true', 'false'] else true)",message="For check-capacity.autoscaling.x-k8s.io, only 'noRetry' parameter is supported with values 'true' or 'false'"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we want to validate on the API level that only noRetry parameter is set.

My understanding is that the entire reason Parameters map exists is easy customisation for non-standard controllers, without requiring an API changes. If we're going to introduce it on the API level, we might just as well add a new field for it (although in this case I would suggest using maxRetries, since it's more flexible). It'd also be cleaner than code in comment, especially with a potentially growing set of parameters/classes to allow.

@mwielgus can you PTAL and decide if this is the way to go or not? Since this is effectively an API level change, it would require SIG chair approval anyway. My opinion is that we shouldn't go with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather avoid adding explicit check for parameters. Parameters may be different for different classes and may come and go.

@aleksandra-malinowska
Copy link
Contributor

/hold

As discussed in review comments, I don't think we want to go forward with this approach. It changes the API definition - even though this definition happens to live in CA directory structure (which is somehow unfortunate), it's the only source-of-truth for ProvisioningRequest API, and not just a part of CA - and effectively obsoletes the Parameters as a catch-all field for extra information specific to the user's needs.

I believe the scope of #7511 should be limited to validation of values of supported parameters on the CA side (in its code). Something like:

  • ignore the unsupported parameters and log a warning
  • validate the values of supported parameters and reject the ProvisioningRequest if they're invalid (with verbose error naming the problematic parameter(s))

If (and when) needed, we could also introduce either CA flags or known parameters to control CA's exact behaviour, for example if a user wants it to reject requests with unsupported parameters.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 6, 2024
@aleksandra-malinowska
Copy link
Contributor

aleksandra-malinowska commented Dec 6, 2024

/kind api-change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add validation of ProvisioningRequest's Parameters
5 participants