-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Address #3937] Add labels to template/metadata if includeTemplates is true #4209
Conversation
Hi @aibarbetta. 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 Once the patch is verified, the new status will be reflected by the 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. |
/retitle [Fix #3937] Add labels to template/metadata if includeSelectors is false |
@aibarbetta: Re-titling can only be requested by trusted users, like repository collaborators. In response to this:
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. |
/ok-to-test |
/test all |
api/krusty/inlinelabels_test.go
Outdated
@@ -70,6 +70,7 @@ spec: | |||
metadata: | |||
labels: | |||
a: b | |||
c: d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does foo: bar
not show up here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test, /app/deployment.yaml
is:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
template:
spec:
containers:
- name: my-deployment
livenessProbe:
httpGet:
path: /healthz
port: 8080
---
apiVersion: example.dev/v1
kind: MyCRD
metadata:
name: crd
^here the pod template has no metadata section. But apparently when kustomize runs and adds the a: b
label, it creates the pod template metadata section. (a: b
pair is configured with includeSelectors: true
)
- pairs:
a: b
includeSelectors: true
After that, the rest of the labels are applied in metadata and template/metadata as expected. The pair foo: bar
is declared before a: b
therefore it never gets added to template/metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natasha41575 I fixed the test by completing the initial deployment.yaml, as I believe selector
and template/metadata
are both required fields of the Deployment kind. Let me know if this is correct
@aibarbetta: This PR has multiple commits, and the default merge method is: merge. 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. |
Giving this a little more thought, and though I agree that this is desired behavior, it is a backwards incompatible change and I'm not sure what we can do that at the moment. To maintain backwards compatibility, I think it would be best to include only |
thanks for the review @natasha41575, I added the |
@natasha41575 @monopole changes done, can you please review? 🙏 |
@natasha41575 can you review please? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM. Just a question about why we are changing a test.
Also, it would be good to get @KnVerey's input on the syntax. @KnVerey this PR proposes
labels:
- pairs:
a: b
includeSelectors: true # this already exists, and adds all the fieldSpecs from commonLabels
- pairs
c: d
includeTemplates: true # new field which will add the label to pod specs, but not matchLabels
/lgtm |
if err != nil { | ||
return nil, err | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't let me comment on it, but the linter is complaining about line 292 below. You can either wrap the error or add //nolint:wrapcheck
to the end of the line.
It would probably be better to use errors.Wrap
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems there was also a failure downloading a module here, can we re-run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why the line number is wrong, but I think it is actually complaining about L249. It shouldn't complain about existing code, and the signature of the error in question is func (sigs.k8s.io/kustomize/api/types.FsSlice).MergeOne(x sigs.k8s.io/kustomize/api/types.FieldSpec) (sigs.k8s.io/kustomize/api/types.FsSlice, error)
.
Regardless, please rebase the PR. We've made major improvements to the linter config since the commit it is current based on, and I'd like to make sure this runs with the latest config before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR is rebased, I wrapped the error in that line and ran the unit tests locally, can we re-run? 🙏
Rerunning the tests! |
/lgtm |
@natasha41575 this is weird, it failed with the same lint error https://github.com/kubernetes-sigs/kustomize/pull/4209/files#annotation_3280759392 did I wrap it correctly? |
@@ -281,7 +289,7 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func( | |||
p := f() | |||
err = kt.configureBuiltinPlugin(p, c, bpt) | |||
if err != nil { | |||
return nil, err | |||
return nil, errors.Wrap(err, "failed to configure transformer") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add // nolint:wrapcheck
to the end of this line to bypass the lint error. I'm not sure why it's still failing.
This reverts commit 0a203df.
Documentation for changes introduced in kubernetes-sigs/kustomize#4209
I opened a PR to add doc here: kubernetes-sigs/cli-experimental#268 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aibarbetta, natasha41575 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 |
Fix #3937