Skip to content

helm can delete resources not created by helm #3319

Closed

Description

@svend

Issue

A helm install can result in a FAILED deploy if resources it is trying to create already exist. Purging the failed deploy results in the existing resources getting deleted.

What I expect

Deleting a helm deployment does not delete resources that were created outside of helm.

What happens

Helm deletes resources that were created outside of helm.

Could helm use the heritage and release labels to determine which resources it owns?

Steps to reproduce

  1. Manually create a kubernetes service resource named example using kubectl.
  2. Install a helm chart that would also create a service named example. This will fail with error like Error: release example failed: services "example" already exists.
  3. helm delete --purge the release. This will delete the example service.

Version information

$ helm version
Client: &version.Version{SemVer:"v2.7.2", GitCommit:"8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.7.2", GitCommit:"8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState:"clean"}

Activity

  1. bacongobbler commented on Jan 8, 2018

    @bacongobbler
    Member

    related comment: #3313 (comment)

  2. technosophos commented on Jan 8, 2018

    @technosophos
    Member

    Since we don't require the usage of those labels, we can't delete based on that. But I agree, this is a bug that we should fix.

    Just to add some specificity for other readers:

    If a chart is installed with the name foo and installs, says, a deployment, then the K8S API server accepts the manifest (e.g. it is well formed), but then fails to create the resources, we end up in a situation in which Helm believes the chart was installed, but k8s does not.

    In a case where the install failed because a deployment exists with the same name, if you run a subsequence helm delete, Helm believes it owns the deployment that pre-dated the failed install. So it will delete it.

    With Helm 3, we can definitely solve this with labels. For Helm 2, we will need to figure out a more creative way to do this -- perhaps by checking that the creation time of the existing resources is equal to (or after) the release creation time.

  3. added
    help wanted
    on Jan 8, 2018
  4. added this to the Upcoming - Minor milestone on Jan 8, 2018
  5. xchapter7x commented on Jan 30, 2018

    @xchapter7x

    @technosophos
    mind if i take a crack at this one?

  6. bacongobbler commented on Jan 31, 2018

    @bacongobbler
    Member

    sure!

  7. xchapter7x commented on Feb 2, 2018

    @xchapter7x

    I had a little time to think on this and explore the code a bit. The discussion so far has been around preventing helm from deleting resources it didn't create, but perhaps we could just prevent it from wrongly claiming ownership in the first place.

    currently in func (s *ReleaseServer) prepareRelease it performs operations like uniqName & validateManifest, would it make sense to add another validation step where we make a Get call using the KubeClient to check if the resource we are about to create already exists?

    It would mean an extra API call, but it would allow us to short circuit on existing resources, before tiller can claim ownership, which would prevent the issue described above.

    Let me know if there are any gaps or things I am missing, or if this is a workable path forward for implementation of a fix.

    Thanks in advance for your comments and suggestions.

    -John

  8. xchapter7x commented on Feb 11, 2018

    @xchapter7x

    hi @bacongobbler, @technosophos, @svend ,

    I have a ready PR in to address this issue. Description and approach is in the PR.

    Let me know your collective thoughts and feedback.
    Thanks in advance.

    pr: (#3477)

    -John

  9. xchapter7x commented on Mar 23, 2018

    @xchapter7x

    hi @bacongobbler, @technosophos,

    i just wanted to check in and see if you've had a chance to take a look at the PR for this issue?
    Let me know your thoughts and how you'd like to proceed. Thanks :)
    pr: (#3477)
    -John

  10. added
    bug
    and removed on Jun 5, 2018
  11. iomv commented on Nov 2, 2018

    @iomv

    We are in the same situation, with already existing services that creates aws' Load Balancers on creation. I don't want to delete the service to get it handled by Helm because it would mean re-creating the Load Balancer and losing all the references in my routing table.
    Any chance we can get an update on this please?

  12. DanHoerst commented on Feb 7, 2019

    @DanHoerst

    Any chance we could get an update on this?

  13. bacongobbler commented on Jun 13, 2019

    @bacongobbler
    Member

    @DanHoerst feel free to give #3477 a try and see if that fixes the issue for you.

  14. bacongobbler commented on Oct 1, 2019

    @bacongobbler
    Member

    fixed in Helm 3 via #6542

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions