VPA: match CronJob pods when jobTemplate pod labels are omitted#9489
VPA: match CronJob pods when jobTemplate pod labels are omitted#9489isumitsolanki wants to merge 2 commits intokubernetes:masterfrom
Conversation
Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: isumitsolanki The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @isumitsolanki! |
|
Hi @isumitsolanki. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
Signed-off-by: Sumit Solanki <sumit.solanki@ibm.com>
|
/ok-to-test |
| func getLabelSelectorFromCronJob(apiObj *batchv1.CronJob) (labels.Selector, error) { | ||
| templateLabels := apiObj.Spec.JobTemplate.Spec.Template.Labels | ||
| if len(templateLabels) == 0 { | ||
| return labels.Everything(), nil |
There was a problem hiding this comment.
I'm not sure that labels.Everything() is the right solution here. I'm pretty sure this will match all pods in that namespace, which may cause performance issues.
There was a problem hiding this comment.
I agree. in large clusters this can be very problematic.
There was a problem hiding this comment.
I never thought in that direction thanks for highlighting this aspect @adrianmoisey @omerap12
what could be the right approach here ?can you please help here ?
There was a problem hiding this comment.
In the original issue where we discussed this, we concluded to document the behaviour, rather than fix it.
There was a problem hiding this comment.
Yup. @adrianmoisey , will it be beneficial if we would print something when user apply VPA with targetRef pointing at CronJob/Job?
There was a problem hiding this comment.
I don't think we can. Returning a warning doesn't feel right for this
What type of PR is this?
/kind bug
What this PR does / why we need it:
When a
CronJobomitsspec.jobTemplate.spec.template.labels, the field isnil. Building the selector viametav1.SetAsLabelSelector(nil)leads tometav1.LabelSelectorAsSelector(nil), i.e.labels.Nothing(), so no pod matched the VPA despite correcttargetRefand parent-controller association. This PR returnslabels.Everything()when the job pod template labels are nil or empty, and adds unit tests inpkg/target.Which issue(s) this PR fixes:
Fixes #9483
Special notes for your reviewer:
Aligns omitted labels with an explicit empty map
labels: {}on the job pod template. If multiple VPAs in one namespace only differed by this path, recommender overlap was already possible with{}; this change makes nil behave the same.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: