-
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
Fix a bug in Generator options #5117
Fix a bug in Generator options #5117
Conversation
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. |
Hi @yutaroyamanaka. 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. |
/ok-to-test /triage accepted |
What's the status of this PR? If it indeed fixes #4833, can we make it at the next release? |
@chulkilee |
@koba1t could you please take a look on this PR? Or could you invite other reviewers? Thanks! Please note that this is one of major blocker to adopt kustomize for our team since we need to specify this to static resources (e.g. sops-encrypted Secrets) |
@yutaroyamanaka |
Hi @yutaroyamanaka |
Thank you for your review. |
/lgtm |
@koba1t what's the plan on this PR? Are there any blockers? |
We need to wait for a review from the maintainer. |
@yutaroyamanaka Can you rebase your PR to retrigger the tests? I will try to take a look in the next week or so |
ed4d755
to
b2190ea
Compare
/label tide/merge-method-squash |
@yutaroyamanaka could you fix the go lint error? It's just complaining not using return value in tests. |
b2190ea
to
0b23711
Compare
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yutaroyamanaka 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 |
@yutaroyamanaka |
|
Hi @yutaroyamanaka |
@koba1t |
@yutaroyamanaka |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. 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. |
As mentioned by @KnVerey in this comment, using both
kustomize.config.k8s.io/behavior
andkustomize.config.k8s.io/needs-hash
as generator options can cause a bug where the hash is not added to themetadata.name
of the generated resource.I reproduced this issue with current master branch as follows.
kustomization.yaml
configmap.yaml
generator.sh
result of kustomize build
If we set
kustomize.config.k8s.io/needs-hash
as a generator option,UpdateResourceOptions
is called fromGenerate
in
api/internal/target/kusttarget.go
.UpdateResourceOptions
sets a build annotationinternal.config.kubernetes.io/needsHashSuffix
to the resource generated by a generator.However, I found out this annotation is removed when
kustomize.config.k8s.io/behavior
option is set.We can confirm this In kustomize/blob/master/api/resmap/reswrangler.go, where
CopyMergeMetaDataFieldsFrom
is called. I believe this method copies the metadata of the origin resource to the one of the generated resource. In merge process, all build annotations, includinginternal.config.kubernetes.io/needsHashSuffix
are removed (see https://github.com/natasha41575/kustomize/blob/master/api/resource/resource.go#L465). My approach is to not deleteinternal.config.kubernetes.io/needsHashSuffix
annotation here.Here is output of this branch
$ ./kustomize build --enable-alpha-plugins --enable-exec . apiVersion: v1 data: a: b c: d kind: ConfigMap metadata: name: cmap-fh478f99mk
Reference: https://kubectl.docs.kubernetes.io/guides/extending_kustomize/#generator-options