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 label filter to job resource #4152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ambersun1234
Copy link

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR add a label filter to Job resource kind to prevent Kueue from intercepting unintended resource instance

Which issue(s) this PR fixes:

Fixes #4141

Special notes for your reviewer:

Does this PR introduce a user-facing change?

User need to include `app.kubernetes.io/managed-by: kueue` label in their Job definition in order to let Kueue intercept it

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Feb 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ambersun1234
Once this PR has been reviewed and has the lgtm label, please assign tenzen-y for approval. For more information see the 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

Copy link

CLA Not Signed

@k8s-ci-robot
Copy link
Contributor

Welcome @ambersun1234!

It looks like this is your first PR to kubernetes-sigs/kueue 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kueue has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 5, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @ambersun1234. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 5, 2025
Copy link

netlify bot commented Feb 5, 2025

Deploy Preview for kubernetes-sigs-kueue ready!

Name Link
🔨 Latest commit aaa9348
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/67a36a4ec72f7f0008e36f88
😎 Deploy Preview https://deploy-preview-4152--kubernetes-sigs-kueue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -85,6 +85,9 @@ webhooks:
path: /mutate-batch-v1-job
failurePolicy: Fail
name: mjob.kb.io
objectSelector:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let me try to understand, with this you narrowed down Kueue webhooks application to jobs with app.kubernetes.io/managed-by: kueue label?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, only Job with app.kubernetes.io/managed-by: kueue label will be intercept by Kueue

@mimowo
Copy link
Contributor

mimowo commented Feb 6, 2025

/hold
We already have a label to indicate if a workload (represented by k8s Job or other Job CRD) is managed by Kueue: kueue.x-k8s.io/queue-name.

@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 Feb 6, 2025
@ambersun1234
Copy link
Author

@mimowo

If there's multiple jobs, each job have different queue name associate with it, then the label kueue.x-k8s.io/queue-name can't work properly, you'll need to include all possible "queue names" to objectselector, which in my opinion is not viable

@mimowo
Copy link
Contributor

mimowo commented Feb 6, 2025

I think the selectors allow to filter just by label key presence, e.g. kubectl get jobs -l kueue.x-k8s.io/queue-name

EDIT: you may need to use matchExpressions , take a look here:

MatchExpressions: []metav1.LabelSelectorRequirement{
{
Key: "kubernetes.io/metadata.name",
Operator: metav1.LabelSelectorOpNotIn,
Values: matchExpressionsValues,
},
},

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

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

I do not think that we should introduce such a label selector.
If you want to add arbitrary label selector, you could add those by your kustomize override, IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: no Indicates the PR's author has not 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Kueue mutation admission webhook should intercept specific resource instance only
5 participants