Skip to content

helm install when resources already exist will fail - #3477

Closed
xchapter7x wants to merge 4 commits into
helm:masterfrom
xchapter7x:master
Closed

xchapter7x wants to merge 4 commits into
helm:masterfrom
xchapter7x:master

Conversation

@xchapter7x

@xchapter7x xchapter7x commented Feb 9, 2018 •

Copy link
Copy Markdown

This is a PR to fix the issue described here: #3319

  • the intent here is to make the client smart enough to fail if a Create call is not able to complete successfully, due to a conflicting pre-existing resource.

I decided to implement this pre-existing resource check within the kubeclient. Reason being, if a Create call can not actually create the resource b/c the resource already exists, then one would expect the call to return an error.

This seemed more appropriate then implementing a check in the tiller package as part of the InstallRelease call, as tiller knows only about installing a release, and that it has a client interface upon which it can call Create. It shouldn't need to know anything about the expected behavior of the client Create call, and its handling of pre-existing resources.

The kubeclient Create implementation borrows the approach taken in the Update call on the kubeclient. Obvious difference being, update will skip pre-existing resources and create will now fail on pre-existing resources.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 9, 2018
@xchapter7x xchapter7x changed the title WIP: Attempt to install when resources already exist will fail helm install when resources already exist will fail Feb 11, 2018
@xchapter7x

Copy link
Copy Markdown
Author

hi @bacongobbler, @technosophos,

I just wanted to follow up and see if you had any thoughts about this PR? Feedback is be welcome and much appreciated. Thanks.

-John

@fejta-bot

Copy link
Copy Markdown

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@fejta-bot

Copy link
Copy Markdown

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale

@bacongobbler

Copy link
Copy Markdown
Member

Hi @xchapter7x. Thanks for taking the time to write up a PR for this. At the time I did not have enough experience with pkg/kube to determine whether or not this was the right fix. Now that I'm more familiar with the codebase, this does seem like the right fix for the problem.

cc @thomastaylor312. What do you think about merging this one into Helm 2 and porting it over to Helm 3? Seems like it'd fix the issues we were discussing about the --atomic flag as well.

@thomastaylor312

Copy link
Copy Markdown
Contributor

The big thing here is that we can’t check in the Create method because that would be too late. It needs to be some validation that occurs before the release object is even created. Otherwise, we end up with a release that contains objects pointing to the existing ones. Let me try porting some of this to Helm 3 as a test

thomastaylor312 added a commit to thomastaylor312/helm that referenced this pull request Sep 30, 2019
Currently, if using the --atomic flag or deleting a release that failed due to an already existing
resource, Helm will deleting those resources that aren't managed by it. This PR fixes the issue
by checking for pre-existing resources during install and upgrade. This is done as a validation
step so the release will not even be started if resources currently exist. This PR is inspired by
@xchapter7x's work in helm#3477.

This also fixes a small bug in upgrade where deletes fail if the resource was already deletes

Fixes helm#6407

Signed-off-by: Taylor Thomas <[email protected]>
@thomastaylor312

Copy link
Copy Markdown
Contributor

I implemented this using your handy function @xchapter7x in #6542 for v3. Based on what I see here with your PR, my one worry is that a release may still get created and cause issues when someone tries to delete it, but I've been going back and forth between the v2 and v3 codebase that I could be wrong.

@xchapter7x

Copy link
Copy Markdown
Author

@thomastaylor312 @bacongobbler
I'm glad this PR ended up adding some value for the community :)

Let me know if I can help with more contributions moving forward.

Keep up the great work 👍

@bacongobbler bacongobbler added the bug Categorizes issue or PR as related to a bug. label Oct 2, 2019
@bacongobbler

Copy link
Copy Markdown
Member

Thanks @xchapter7x! Given the complexity in this change we aren't planning on moving this through for Helm 2, however thank you for catalyzing the movement on Helm 3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants