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

Wishlist of CEL libraries #124490

Open
7 tasks
alculquicondor opened this issue Apr 23, 2024 · 14 comments
Open
7 tasks

Wishlist of CEL libraries #124490

alculquicondor opened this issue Apr 23, 2024 · 14 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@alculquicondor
Copy link
Member

alculquicondor commented Apr 23, 2024

What would you like to be added?

This is just my wishlist. We need all of them, so no specific priority.

  • Regexes for object names, label keys, values, container names, etc. I think this one is already in the works?
  • validate the type metav1.Conditions
  • simple functions to check if conditions are true/false.
  • taints and tolerations
  • labelSelectors (we don't need this one, but it will probably be useful for some projects)
  • The ultimate validation: Pod templates, but worth starting with just containers :) Very useful for job CRDs.
  • ... (waiting for feedback)

Why is this needed?

As we were working on transitioning Kueue validation webhooks to CEL, we ended up with a lot of repeated validation lines. In some cases, validating something is so involved that we decided to keep most of the webhooks, otherwise readability would be significantly impacted.

@alculquicondor alculquicondor added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 23, 2024
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 23, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@alculquicondor
Copy link
Member Author

/sig api-machinery
cc @cici37 @jpbetz

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 23, 2024
@alculquicondor
Copy link
Member Author

@IrvingMg, @trasc did I miss anything important?

@sftim
Copy link
Contributor

sftim commented Apr 23, 2024

What do you mean by Pod templates @alculquicondor?

One pattern I'd like to see used more: when you create something that embeds a Pod template, the controller for that kind tries to dry-run make a PodTemplate. That way you get one place to put customer validation (eg a ValidatingAdmissionPolicy), and it can apply to lots of API kinds without repetition.

@alculquicondor
Copy link
Member Author

One pattern I'd like to see used more: when you create something that embeds a Pod template, the controller for that kind tries to dry-run make a PodTemplate.

Interesting. I've never seen that. It sounds bullet proof from a validation perspective. Is there dry-run support in the apiserver? But then it would have to be called from the webhook?

@jpbetz
Copy link
Contributor

jpbetz commented Apr 23, 2024

Regexes for object names, label keys, values, container names, etc. I think this one is already in the works?

Yes, this one is progressing here: #123572 (cc @alexzielenski)

@jpbetz
Copy link
Contributor

jpbetz commented Apr 23, 2024

The ultimate validation: Pod templates, but worth starting with just containers :) Very useful for job CRDs.

We might do something special to validated embedded types like this that doesn't involved CEL. But yes, I agree there is a huge need here. Do you happen to have any references to specific use cases? I'm working on accumulating those.

@liggitt
Copy link
Member

liggitt commented Apr 23, 2024

@alculquicondor
Copy link
Member Author

Re: dry-run support
I see. Still, that would imply that a webhook has to do an API call. Would you still recommend this?

Do you happen to have any references to specific use cases?

  1. All of the kubeflow job CRDs, to start. They will eventually fail at Pod or k8s Job creation, if the template is wrong, as they are not doing any validation.
  2. Kueue Workload objects https://kueue.sigs.k8s.io/docs/concepts/workload/. These are created out of existing Jobs, Pods, or arbitrary CRDs (like Kubeflow jobs). The only problematic case is the last one.

@kannon92
Copy link
Contributor

@kannon92
Copy link
Contributor

kannon92 commented Apr 23, 2024

@danielvegamyhre was looking into kubectl-validate as a way to validate templates as a library.

@IrvingMg
Copy link

@IrvingMg, @trasc did I miss anything important?

Not that I can think of. That's everything we need for now.

@alculquicondor
Copy link
Member Author

WRT conditions, right now, we have to do things like this:

has(self.status) && has(self.status.conditions) && self.status.conditions.exists(c, c.type == 'QuotaReserved' && c.status == 'True')

It would be good to have a simplified experience, similar to meta.IsConditionTrue in golang.

I added a separate item for this.

@liggitt
Copy link
Member

liggitt commented Apr 26, 2024

fwiw, optionals can make that more concise:

self.?status.?conditions.orValue([]).exists(c, c.type == 'QuotaReserved' && c.status == 'True')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

7 participants