-
Notifications
You must be signed in to change notification settings - Fork 227
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
Implements DependencyUpdate for helm charts #2135
Conversation
331ccd3
to
c57393b
Compare
A new flag `disableDependencyUpdate` is added to the `fleet.yaml` file in order to disable the feature, which is active by default. A new package `helmupdater` is added to implement the dependencies update. The implementation is based on helm's when ussing the `--dependency-update` flag in the install command. Dependencies are applied to the bundle (upstream) to they're resolved already when applying downstream. Refers to: rancher#1672 Signed-off-by: Xavi Garcia <[email protected]>
c57393b
to
999dc47
Compare
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.
Nice work, thanks for this!
Leaving a few comments, mostly nitpicks.
presentInBundleResources(path.Join(tmpDir, "Chart.lock"), bundle.Spec.Resources) | ||
presentInBundleResources(path.Join(tmpDir, "charts/config-chart-0.1.0.tgz"), bundle.Spec.Resources) | ||
|
||
return !bundle.Spec.KeepResources |
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 is KeepResources
relevant here? Would this be a leftover from reusing specs of already existing test cases? (same question about the test description)
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 is not, indeed. I've deleted that.
Signed-off-by: Xavi Garcia <[email protected]>
Signed-off-by: Xavi Garcia <[email protected]>
Changed from disableDependencyUpdate to disableDepsUpdate Signed-off-by: Xavi Garcia <[email protected]>
return true | ||
}).Should(BeTrue()) |
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 think this doesn't make much sense: either we should return an expression, which may or may not evaluate as true
, or skip this altogether: do we even need Eventually
blocks 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.
I thought that was because we don't know when the Bundle
is going to be ready so Eventually
waits up to its timeout (5 minutes) for success.
It would only reach that return true
statement when all the statements before that one are successful (at least that's what I got from the tests I did)
As there are quite a few files to check I thought it was better to do that than returning a chain of booleans.
(This file is found and that file is found and... etc)
Given I'm new to Ginkgo I guess there are better ways of doing what I need... I'll investigate. :/
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.
Since the test uses the cli to create the bundle it will be ready when the cli exists. The buffer buf
will be in it's final state, as soon as cli.GetBundleFromOutput
returns. Eventually
is great when we're waiting for resources to appear in k8s. If I understood that correctly, I'd definitely remove them.
I also see a lot of helper functions like onlyPresentInBundleResources
, these could be custom matchers: https://onsi.github.io/gomega/#adding-your-own-matchers
But I don't think we're using those anywhere else, no need to do change it.
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've tested deleting the Eventually
statements and running in a loop for 10000 times and it passed.
So... Eventually
statements deleted.
I've also added a couple of custom matchers and deleted the helpers.
Also... I've changed the already existing tests to use the custom matchers and removed the Eventually
statements to avoid future confusions and make the whole file consistent.
57f45d9
to
70fb948
Compare
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.
Thanks for converting existing test cases to using matchers, they're much more readable now!
Expect(len(root.Spec.Resources)).To(Equal(5)) | ||
|
||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(deploymentA.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(deploymentA.Spec.Resources)) |
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.
Aren't these two the same check? You have converted it correctly, but I suspect there was a typo in the test case in the first place, eg.:
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(deploymentA.Spec.Resources)) | |
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/deployment.yaml").To(bePresentInBundleResources(deploymentA.Spec.Resources)) |
(disclaimer: I haven't tested this)
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(deploymentA.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentC/fleet.yaml").To(bePresentInBundleResources(deploymentC.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) |
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.
Same doubt as above:
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | |
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/deployment.yaml").To(bePresentInBundleResources(root.Spec.Resources)) |
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentA/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentB/svc.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | ||
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentC/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) |
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 believe one check is missing from the previous version:
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentC/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | |
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentC/fleet.yaml").To(bePresentInBundleResources(root.Spec.Resources)) | |
Expect(cli.AssetsPath + "nested_mixed_two_levels/nested/deploymentD/deployment.yaml").To(bePresentInBundleResources(root.Spec.Resources)) |
Eventually is not needed when testing for resources in bundles as we get the bundle from `cli.GetBundleListFromOutput` and the buffer read will be in its final state once `cli.GetBundleListFromOutput` returns. Also addind custom Gomega matchers to avoid using helper functions and to get the exact line when any test assertion fails. Already existing tests have been changed to use the custom matchers and don't use Eventually, also. Signed-off-by: Xavi Garcia <[email protected]>
70fb948
to
28c9c5b
Compare
Updates dependencies in helm charts by default.
A new flag
disableDependencyUpdate
is added to thefleet.yaml
file in order to disable the feature.If you don't specify anything, dependencies will be updated.
In order to avoid dependency updates, use
disableDependencyUpdate: true
in thefleet.yaml
file.A new package
helmupdater
is added to implement the dependencies update.The implementation is based on helm's when ussing the
--dependency-update
flag in the install command.Dependencies are applied to the bundle (upstream) so they're resolved already when applying downstream.
Note. It also adds a new step when running
e2e
tests, because the new dependency update tests rely on both, the helm-registry and the git-serverRefers to: #1672