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 CEL rules to ResourceFlavor #1958

Merged
merged 5 commits into from
Apr 11, 2024

Conversation

IrvingMg
Copy link
Contributor

@IrvingMg IrvingMg commented Apr 9, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR replaces some of the validations executed by webhooks for the resourceflavor type with CRD validation rules.

Which issue(s) this PR fixes:

Relates to #463

Special notes for your reviewer:

Due to the resource constraints imposed by the API Server, only have been replaced those validations which costs don't exceed the limits.

Does this PR introduce a user-facing change?

Added CRD validation rules to ResourceFlavor.

ACTION REQUIRED: Requires Kubernetes 1.25 or newer

@k8s-ci-robot k8s-ci-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Apr 9, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 9, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @IrvingMg. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 9, 2024
Copy link

netlify bot commented Apr 9, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit a73a0c0
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/6617ee7ef6492100080c2842

@trasc
Copy link
Contributor

trasc commented Apr 9, 2024

/assign

@alculquicondor
Copy link
Contributor

/ok-to-test
/assign @trasc

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 9, 2024
@@ -78,6 +79,11 @@ type ResourceFlavorSpec struct {
// +optional
// +listType=atomic
// +kubebuilder:validation:MaxItems=8
// +kubebuilder:validation:XValidation:rule="self.all(x, !has(x.key) ? x.operator == 'Exists' : true)", message="operator must be Exists when 'key' is empty, which means 'match all values and all keys'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for discussion, from maintenance, do you guys think this is more simple comparing to the codes.

Copy link
Contributor

Choose a reason for hiding this comment

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

From maintenance POV it depends on how the rules look, From a runtime POV if we are able to fully drop the webhook for a type (like it was the case for local queue) then it's a win.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense, apply the same policy through the whole project is important to avoid confusion, unless we can't fully remove the validation.

Copy link
Contributor

@trasc trasc left a comment

Choose a reason for hiding this comment

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

Generally LGTM, but unfortunately we cannot do to much for resource flavors.

pkg/webhooks/resourceflavor_webhook.go Outdated Show resolved Hide resolved
pkg/webhooks/resourceflavor_webhook.go Outdated Show resolved Hide resolved
pkg/webhooks/workload_webhook.go Outdated Show resolved Hide resolved
Copy link
Contributor

@trasc trasc left a comment

Choose a reason for hiding this comment

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

/lgtm

Even if we ware not able to do too much about this.

@alculquicondor maybe for a followup, If we move the finalizer addition from the defaulter (and fully manage that in the controller) we can drop the mutation web-hook for this.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 354007c50dbf3b3d2fc28d08bae7dbde2d433f29

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot requested a review from trasc April 11, 2024 14:06
@@ -111,8 +111,6 @@ func validateNodeTaints(taints []corev1.Taint, fldPath *field.Path) field.ErrorL
if errs := validation.IsValidLabelValue(currTaint.Value); len(errs) != 0 {
allErrors = append(allErrors, field.Invalid(idxPath.Child("value"), currTaint.Value, strings.Join(errs, ";")))
}
// validate the taint effect
allErrors = append(allErrors, validateTaintEffect(&currTaint.Effect, false, idxPath.Child("effect"))...)

// validate if taint is unique by <key, effect>
if len(uniqueTaints[currTaint.Effect]) > 0 && uniqueTaints[currTaint.Effect].Has(currTaint.Key) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can replace uniqueness checks by using +listType=map and adding the appropriate keys to use.

But we can leave that for a follow up PR.

Copy link
Contributor

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1a112b525742df57bc6e54b1afc3c99638fdbb95

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, IrvingMg

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit aa2afc1 into kubernetes-sigs:main Apr 11, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.7 milestone Apr 11, 2024
@IrvingMg IrvingMg deleted the add-resourceflavor-cel-rules branch April 12, 2024 08:14
vsoch pushed a commit to researchapps/kueue that referenced this pull request Apr 18, 2024
* Add CEL rules to ResourceFlavor

* Update comments

* Add issue reference to TODO comment

* Group similar test cases with DescribeTable

* Update validation rule
kannon92 pushed a commit to openshift-kannon92/kubernetes-sigs-kueue that referenced this pull request Nov 19, 2024
* Add CEL rules to ResourceFlavor

* Update comments

* Add issue reference to TODO comment

* Group similar test cases with DescribeTable

* Update validation rule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants