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

Allow diamond structure of kustomize import #1253

Closed
wants to merge 5 commits into from

Conversation

jbrette
Copy link
Contributor

@jbrette jbrette commented Jun 25, 2019

  • This situation happens in project which try to aggregate multiple
    components in different folders sharing the same base folder.
  • Improve ResMap Append to allow diamond includes by comparing Id and Resource during Append.
  • Improve VarSet Merge method to allow diamond includes by comparing Name and Value during Merge.

It addresses the following issues:
Support composition in kustomize #1251

and

Error when composing several identical bases that use the same var: "var ... already encountered" #1248

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 25, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jbrette
To complete the pull request process, please assign liujingfang1
You can assign the PR to them by writing /assign @liujingfang1 in a comment when ready.

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

@k8s-ci-robot k8s-ci-robot requested review from justinsb and mengqiy June 25, 2019 21:25
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 25, 2019
@jbrette
Copy link
Contributor Author

jbrette commented Jun 25, 2019

/assign @Liujingfang1

pkg/resmap/resmap.go Outdated Show resolved Hide resolved
// name already exists
if !reflect.DeepEqual(v, vs.set[v.Name]) {
return fmt.Errorf(
"var '%s' already encountered", v.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is what vs.Contains does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No vs.Contains is using the name of the variable. The DeepEquals allows to detect that we are trying to insert a new variable with the same name but a different definition.

@jbrette jbrette force-pushed the diamond branch 3 times, most recently from c846b09 to 387029b Compare June 27, 2019 05:09
@jbrette jbrette changed the title Allow diamond structure of kustomize import WIP: Allow diamond structure of kustomize import Jun 27, 2019
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 27, 2019
@jbrette jbrette changed the title WIP: Allow diamond structure of kustomize import Allow diamond structure of kustomize import Jun 28, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 28, 2019
@jbrette
Copy link
Contributor Author

jbrette commented Jun 28, 2019

@Liujingfang1 @monopole Extended diamond test showing simple sharing of a common folder between two component1 and component2 before beeing aggregate together in myapp.

@jbrette jbrette force-pushed the diamond branch 4 times, most recently from 9cdbfb1 to 0e1242d Compare July 1, 2019 02:11
jbrette added 5 commits July 1, 2019 11:36
- This situation happens in project which try to aggregate multiple
  components in different folders sharing the same base folder.
- Improve Resource Append to allow diamond include.
- Improve VarSet Merge method to allow diamond include.
- Variables not involving nameprefix are resolved properly.
- variables resolved properly for first pod.
- Still quite a lot of work to get the variable resolved properly
  for Pod2.
This commit demonstrates how a common resource can be included
accross different components.
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 1, 2019
@monopole
Copy link
Contributor

monopole commented Jul 1, 2019

I agree with the spirit of this PR, but not the implementation. The PR didn't require changes to many tests, but since i wrote a good fraction of them, they assume that the resmap disallows Id collisions, and so don't test for it. Allowing it will cause new behavior and new bugs.

We can't just toss in a big change like this without a flag that enables it, and a coherent testing and example strategy. Started an issue here: #1292

At the time of writing this note, my understanding is that the particular issue (#1251) this PR wants to address can be solved by writing different kustomization files.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2019
@k8s-ci-robot
Copy link
Contributor

@jbrette: PR needs rebase.

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.

@jbrette
Copy link
Contributor Author

jbrette commented Jul 1, 2019

PR has been merged and designed explicitly to generate merge conflict.

@jbrette jbrette closed this Jul 1, 2019
@monopole
Copy link
Contributor

monopole commented Jul 1, 2019

#1291 added a test to assure the resmap class invariant (unique Ids) was protected, so that a PR that violated that assumption would be flagged. It's a dangerous assumption to violate, and we don't have enough coverage on it. This PR brought that fact to my attention, that is all. Thanks for the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants