-
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
components are applied after generators, before transformers #5170
components are applied after generators, before transformers #5170
Conversation
/approve @annasong20, when you give this PR a review could you also build off the branch to be a second verifier that it fixes #5141? |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: koba1t, 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 |
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.
Only readability comments. Great spacing and go.work.sum
fixes.
api/internal/target/kusttarget.go
Outdated
@@ -238,6 +234,11 @@ func (kt *KustTarget) accumulateTarget(ra *accumulator.ResAccumulator) ( | |||
return nil, errors.WrapPrefixf( | |||
err, "merging vars %v", kt.kustomization.Vars) | |||
} | |||
// components are accumulated last. |
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 comment, can we explain why "components are accumulated last"?
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 add a comment at
983165a.
Do you think this comment is enough to explain it?
api/krusty/component_test.go
Outdated
input []FileGen | ||
expectedOutput string | ||
}{ | ||
"a": { |
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.
Can we rename the test to something more descriptive? For example, "after generators".
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.
Oh!
Sorry, I forgot to fix the test name.
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 fixed it at 0c38baa.
Fixes the issue! |
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 @annasong20 I have done a fix. |
/hold For discussion |
api/internal/target/kusttarget.go
Outdated
@@ -238,6 +234,12 @@ func (kt *KustTarget) accumulateTarget(ra *accumulator.ResAccumulator) ( | |||
return nil, errors.WrapPrefixf( | |||
err, "merging vars %v", kt.kustomization.Vars) | |||
} | |||
// components are accumulated last. | |||
// components are expected to execute after reading resources, adding generators, and applying transformers. | |||
ra, err = kt.accumulateComponents(ra, kt.kustomization.Components) |
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.
As discussed in meeting, we decided to move this to after generators, but before transformers
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.
@koba1t I'll review the PR again after this change.
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.
@annasong20
I moved the code and added a test case. 1d0a14d
Could you recheck it?
/tide merge-method-squash |
/label tide/merge-method-squash |
FYI, we are seeing some kustomize build failures associated with this commit. I'm working to isolate the source and create a simple test case. |
I believe the failures we're seeing are expected given this PR's description, but if someone is willing to confirm, I'd appreciate it. My understanding is that our current pattern (generate a configmap in the component and merge it in the top-level kustomization.yaml) will need to be inverted (generate a configmap in the top-level kustomization.yaml and merge it in the component). Is that accurate? kustomization.yaml: components:
- component-example
configMapGenerator:
- files:
- datafile.txt
name: cm-for-datafile
behavior: merge component-example/kustomization.yaml: kind: Component
generators:
- generators.yaml component-example/generators.yaml: apiVersion: builtin
kind: ConfigMapGenerator
metadata:
name: cm-for-datafile
labels:
app.kubernetes.io/name: cm-for-datafile datafile.txt is empty. Results from kustomize builds before and after this commit:
|
@ephesused Yes, I believe that should solve the problem. Thank you for the detailing your setup and feel free to leave any feedback for this change at #5141. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [kubernetes-sigs/kustomize](https://github.com/kubernetes-sigs/kustomize) | minor | `v5.0.3` -> `v5.1.0` | | [zellij-org/zellij](https://github.com/zellij-org/zellij) | patch | `v0.37.0` -> `v0.37.1` | --- ### Release Notes <details> <summary>kubernetes-sigs/kustomize</summary> ### [`v5.1.0`](https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize/v5.1.0) [Compare Source](https://github.com/kubernetes-sigs/kustomize/compare/kustomize/v5.0.3...kustomize/v5.1.0) ##### Highlights Components are now applied after generators: [https://github.com/kubernetes-sigs/kustomize/pull/5170](https://github.com/kubernetes-sigs/kustomize/pull/5170) We made this change cautiously as we want to avoid user friction when updating kustomize; however we felt that it is a bug that resources from `resources` and resources from generators are treated differently. Given that components is currently an alpha feature, we felt that now was the time to adjust if ever. We are currently working on on [https://github.com/kubernetes-sigs/kustomize/issues/4402](https://github.com/kubernetes-sigs/kustomize/issues/4402), which will make the ordering of `resources`, `components`, and `generators` customizable in the kustomization file. Please use that issue for tracking if you are blocked from upgrading kustomize for this reason, and we hope to have it available soon. See [https://github.com/kubernetes-sigs/kustomize/issues/5141](https://github.com/kubernetes-sigs/kustomize/issues/5141) for more detailed discussion. ##### Bug fixes: [#​5030](https://github.com/kubernetes-sigs/kustomize/issues/5030): `kustomize edit` will return an error if there is no matching path [#​5170](https://github.com/kubernetes-sigs/kustomize/issues/5170): components are now applied after generators ##### Dependency updates [#​5186](https://github.com/kubernetes-sigs/kustomize/issues/5186): Update gnostic dependency with gnostic-models [#​5187](https://github.com/kubernetes-sigs/kustomize/issues/5187): Bump to go 1.20 [#​5212](https://github.com/kubernetes-sigs/kustomize/issues/5212): pin to kyaml v0.14.3 [#​5213](https://github.com/kubernetes-sigs/kustomize/issues/5213): pin to cmd/config v0.11.3 [#​5214](https://github.com/kubernetes-sigs/kustomize/issues/5214): pin to api 0.14.0 </details> <details> <summary>zellij-org/zellij</summary> ### [`v0.37.1`](https://github.com/zellij-org/zellij/releases/tag/v0.37.1) [Compare Source](https://github.com/zellij-org/zellij/compare/v0.37.0...v0.37.1) ##### RELEASE IN PROGRESS Thank you for your patience! </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/scottames/dots). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMzEuMCIsInVwZGF0ZWRJblZlciI6IjM1LjEzMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
/retitle components are applied after generators, before transformers |
That's right. Thanks! |
kubernetes-sigs#5170) * change: components apply after all generator and transformer applied * fix name for a test case * add comment about when the components will be executed * components are applied before transformer
…release Kustomize release 5.1.0 (our CI job uses this version) made the changes in the order of processing of resources, components , generators and transformers. That requires that our top level kustomization yamls should create the configmaps, rather than replace it, because with 5.1.0, components will be processed after generators, so there won't be any existing configmap to replace. Following issue has more details about it: kubernetes-sigs/kustomize#5170 Signed-off-by: Anil Kumar Vishnoi <avishnoi@redhat.com>
Kustomize release 5.1.0 (our CI job uses this version) made the changes in the order of processing of resources, components , generators and transformers. That requires that our top level kustomization yamls should create the configmaps, rather than replace it, because with 5.1.0, components will be processed after generators, so there won't be any existing configmap to replace. Following issue has more details about it: kubernetes-sigs/kustomize#5170 Signed-off-by: Anil Kumar Vishnoi <avishnoi@redhat.com>
Kustomize release 5.1.0 (our CI job uses this version) made the changes in the order of processing of resources, components , generators and transformers. That requires that our top level kustomization yamls should create the configmaps, rather than replace it, because with 5.1.0, components will be processed after generators, so there won't be any existing configmap to replace. Following issue has more details about it: kubernetes-sigs/kustomize#5170 Signed-off-by: Anil Kumar Vishnoi <avishnoi@redhat.com>
fix: #5141