Skip to content

Unable to perform helm upgrade due to resource conflict #6850

Closed

Description

@efernandes-dev-ops

Output of helm version: v3.0.0-rc.1

Output of kubectl version: Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T12:36:28Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.10-eks-5ac0f1", GitCommit:"5ac0f1d9ab2c254ea2b0ce3534fd72932094c6e1", GitTreeState:"clean", BuildDate:"2019-08-20T22:39:46Z", GoVersion:"go1.11.13", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): AWS

Seem to be experiencing a weird bug when doing helm upgrade. The error states "Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists. Unable to continue with update: existing resource conflict: kind: ServiceMonitor, namespace: dcd, name: bid-management".

We've tested on the following helm versions:

Helm Version:"v3.0.0-beta.2", "v3.0.0-beta.3"

We get the following error - "Error: UPGRADE FAILED: no ServiceMonitor with the name "bid-management" found". Though I can confirm it exists.

Helm Version:"v3.0.0-rc.1", "3.0.0-beta.4", "3.0.0-beta.5"

We get the error above "Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists. Unable to continue with update: existing resource conflict: kind: ServiceMonitor, namespace: dcd, name: bid-management"

Activity

  1. bacongobbler commented on Oct 31, 2019

    @bacongobbler
    Member

    Can you provide a set of steps to reproduce the issue?

  2. efernandes-dev-ops commented on Nov 5, 2019

    @efernandes-dev-ops
    Author

    @bacongobbler Apologies for the delay. Realised it's harder to reproduce locally with minikube since we've got everything setup for/with AWS EKS. At the moment I can confirm the apiVersion of the serviceMonitor doesn't change so it doesn't seem to be a relation to #6583.

    When I run helm template the first time:

    ---
    # Source: k8s-service/templates/servicemonitor.yaml
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: bid-management
      namespace: dcd
      labels:
        chart: k8s-service-v0.0.11
        app: bid-management
        heritage: "Helm"
        release: prometheus
    spec:
      endpoints:
          - honorLabels: true
            interval: 10s
            path: /prometheus
            port: metrics
            scheme: http
            scrapeTimeout: 10s
      selector:
        matchLabels:
          app.kubernetes.io/name: bid-management
    

    After upgrading and once the resource gets created successfully, I run helm template again and get back the following below:

    ---
    # Source: k8s-service/templates/servicemonitor.yaml
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      name: bid-management
      namespace: dcd
      labels:
        chart: k8s-service-v0.0.11
        app: bid-management
        heritage: "Helm"
        release: prometheus
    spec:
      endpoints:
          - honorLabels: true
            interval: 10s
            path: /prometheus
            port: metrics
            scheme: http
            scrapeTimeout: 10s
      selector:
        matchLabels:
          app.kubernetes.io/name: bid-management
    

    After running helm upgrade a second time, I get back the error mentioned above

    Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists. Unable to continue with update: existing resource conflict: kind: ServiceMonitor, namespace: dcd, name: bid-management

  3. efernandes-dev-ops commented on Nov 5, 2019

    @efernandes-dev-ops
    Author

    @bacongobbler Going to still try and re-produce the steps locally with minikube but might take longer than expected.

  4. aespejel commented on Nov 5, 2019

    @aespejel

    Facing the same issue here. @bacongobbler , @efernandes-ANDigital
    kubectl version: 1.14.7
    kubernetes version 1.15 (PKS)
    First time happened to me using Helm v3.0.0-rc.1, after updating to Helm v3.0.0-rc.2 this is still happening.
    Made a rollback successfully to the previous state with rc.2 and upgraded again but it didn't solved it: after upgrading successfully trying a new upgrade gave the same error message.
    helm diff shows no issues (it detects the resources correctly), and even if I look inside the secret related to the revision, it shows the resources there, so it shouldn't try to re-deploy them.
    Not a complex chart, just using range to iterate a list (~100 elements) to generate some resources (namespaces, configmaps, etc.)

    Cannot repro it (tried on GKE)

  5. thomastaylor312 commented on Nov 6, 2019

    @thomastaylor312
    Contributor

    @aespejel What kinds of resources did it fail on?

  6. aespejel commented on Nov 6, 2019

    @aespejel

    Namespaces, which makes sense having in mind the order helm is trying to apply manifests, right @thomastaylor312 ?

  7. thomastaylor312 commented on Nov 6, 2019

    @thomastaylor312
    Contributor

    Yep, Namespaces go first, but I was just checking if this was happening with specific kinds of resources or with an assortment

  8. efernandes-dev-ops commented on Nov 11, 2019

    @efernandes-dev-ops
    Author

    Just to add we noticed something else, upon disabling the service monitor. When running helm upgrade, it returns back a success message "Release "bid-mangement" has been upgraded. Happy Helming! etc. However upon checking the api-resources servicemonitors we still see the servicemonitor that was created.

  9. efernandes-dev-ops commented on Nov 11, 2019

    @efernandes-dev-ops
    Author

    What we've just noticed is for the same charts with other services it works just fine and we don't have the issue. The services use the same exact charts with just a few configuration changes for the services....very weird

  10. vakaobr commented on Nov 14, 2019

    @vakaobr

    The problem also happen while trying to install a chart (e.g. prometheus-operator), if the install fails and you try to install it again, helm complains about resource conflict, and if you try to remove the chart, complains saying it never been deployed.

  11. aespejel commented on Nov 17, 2019

    @aespejel

    @vakaobr I doubt it's the same issue. When the first install fails (and only with the first install), as you noticed, helm doesn't make a release. Hence helm wont have any information about a release to compare with already deployed resources and will try to install them showing that message because actually some of the resources were installed. You can probably solve this by using --atomic with the installation or using helm upgrade --install --force being careful with the --force since it will delete and re-create resources.
    Here we are facing an issue that happens with already successfully installed charts.

  12. aespejel commented on Nov 17, 2019

    @aespejel

    Update: still happening after updating to helm v3.0.0 (stable). @efernandes-ANDigital , @bacongobbler , @thomastaylor312
    If I use helm diff, it shows NO differences, if I use helm upgrade --install --dry-run, it fails with the following error: "Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists."
    Using helm get manifest (of the last release), shows these resources.
    Using helm template shows theses resources too.
    Maybe this is related with how helm compares resources with the manifest vs the templates?
    I'm creating resources iterating a list with range, could it be related with this?
    This piece of code maybe?

  13. aespejel commented on Nov 25, 2019

    @aespejel

    Workaround:
    Running the upgrade --install with --dry-run --debug and -v 10 option showed us that helm was somehow using some really old revisions. We deleted all revisions but the last 2 and it started to work again.

  14. bacongobbler commented on Nov 25, 2019

    @bacongobbler
    Member

    Did you manage to save the release ledger before deleting them? Would've been helpful to reproduce the issue if we had our hands on a solid reproducible case.

  15. 34 remaining items

  16. bacongobbler commented on Feb 4, 2020

    @bacongobbler
    Member

    Any suggestions here?

    #7219 (comment)

  17. topikachu commented on Feb 5, 2020

    @topikachu

    @bacongobbler
    I will show how kubernetes hanlde multiple API versions from design, code, and runtime.

    1. Desing doc
      https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#operational-overview.
      There is an example in the doc on how to create a resource in v7beta1 and retrieve in v5. So from kubernetes design perspective, it allows a single object conversion among multiple versions.

    The conversion process is logically a "star" with the internal form at the center. Every versioned API can be converted to the internal form (and vice-versa)

    1. Kubernetes source code
      As I mentioned above, there are such conversions
      https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/apps/v1/conversion.go Convert_v1_DeploymentSpec_To_apps_DeploymentSpec and Convert_apps_DeploymentSpec_To_v1_DeploymentSpec
      Also, https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/apps/v1beta2/conversion.go Convert_v1beta2_DeploymentSpec_To_apps_DeploymentSpec and Convert_apps_DeploymentSpec_To_v1beta2_DeploymentSpec.
      The code use the interal data structure as a hub in different versions.

    2. Runtime behavior
      I use a 1.14 cluster and kubectl.
      kubectl get -n kube-system deployment coredns -o yaml -v 8
      Force to use another api version
      kubectl get -n kube-system deployment.v1.apps coredns -o yaml -v 8
      You can see a single object (by its uid) can be retrieve by multiple API versions.

  18. richardmatthewsdev commented on Feb 10, 2020

    @richardmatthewsdev

    Hey,

    I am having the same issue. My issue is regarding a pre existing stateful set. Any advice would be much appreciated.

    Thanks,
    Richard

  19. pho-enix commented on Feb 12, 2020

    @pho-enix
    Contributor

    Let's open up discussions:
    #7575

  20. hunyhabib commented on Feb 13, 2020

    @hunyhabib

    Hello,

    I am facing same issue the only think i have done i upgraded from helm 2.14.1 to latest, we are getting the error as mentioned above : **rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: kind: Service, namespace: *, name: *** . All stuff mentioned up about deleting that wont work for us as this is production and the API is critical with 0 down time required. kindly assist ...

    Thanks
    Hany

  21. pgporada commented on Feb 20, 2020

    @pgporada

    Here's a dirty hack that we use whenever a resource, such as a PV or PVC, already exists and we don't want to delete it, but do want to upgrade containers. This typically happens whenever we do a helm upgrade whatever and the old deployment and new deployment get stuck in a race.

    kubectl get deployments -n monitoring
    kubectl get -n monitoring deployment/prometheus-operator-grafana -o jsonpath="{.spec.replicas}"
    
    # Set spec.replicas to 0
    kubectl edit -n monitoring deployments/prometheus-operator-grafana
    watch -n1 -d "kubectl get pods -n monitoring"
    
    # Once all pods have terminated, set the spec.replicas back to 1 or whatever value you want
    kubectl edit -n monitoring deployments/prometheus-operator-grafana
    watch -n1 -d "kubectl get pods -n monitoring"
    
    # At this point you'll have an updated pod/deployment/whatever
    
  22. revmischa commented on Feb 25, 2020

    @revmischa

    I got this error just following the basic tutorial

  23. dkirrane commented on Mar 10, 2020

    @dkirrane

    Hitting this for a ClusterRoleBinding when installing kubernetes dashboard chart

    Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists. Unable to continue with update: existing resource conflict: namespace: , name: kubernetes-dashboard, existing_kind: rbac.authorization.k8s.io/v1, Kind=ClusterRoleBinding, new_kind: rbac.authorization.k8s.io/v1, Kind=ClusterRoleBinding
    
  24. tuxknight commented on Mar 12, 2020

    @tuxknight

    Same issue when installing chart in two namespaces. My chart depends on prometheus-operator chart which will create ClusterRole .
    Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: kind: ClusterRole, namespace: , name: p8s-operator

  25. cforce commented on Mar 14, 2020

    @cforce

    Same here. I migrated the helm2 to a helm 3 deployment and afterwards its no longer upgradeable because of the same error

    ./helm upgrade public-nginx-ingress stable/nginx-ingress --install --namespace ingress --wait -f public-nginx-ingress.yaml coalesce.go:199: warning: destination for extraContainers is a table. Ignoring non-table value [] coalesce.go:199: warning: destination for extraVolumes is a table. Ignoring non-table value [] coalesce.go:199: warning: destination for extraVolumeMounts is a table. Ignoring non-table value [] Error: UPGRADE FAILED: rendered manifests contain a new resource that already exists. Unable to continue with update: existing resource conflict: namespace: , name: public-nginx-ingress, existing_kind: rbac.authorization.k8s.io/v1, Kind=ClusterRole, new_kind: rbac.authorization.k8s.io/v1, Kind=ClusterRole
    I tried to skip the rbac part, ais it already seems to exists and don't need to established again
    Then i get the next issue
    ./helm upgrade public-nginx-ingress stable/nginx-ingress --install --namespace ingress --wait -f public-nginx-ingress.yaml --set rbac.create=false coalesce.go:199: warning: destination for extraContainers is a table. Ignoring non-table value [] coalesce.go:199: warning: destination for extraVolumeMounts is a table. Ignoring non-table value [] coalesce.go:199: warning: destination for extraVolumes is a table. Ignoring non-table value [] Error: UPGRADE FAILED: cannot patch "public-nginx-ingress-controller-metrics" with kind Service: Service "public-nginx-ingress-controller-metrics" is invalid: spec.clusterIP: Invalid value: "": field is immutable && cannot patch "public-nginx-ingress-controller" with kind Service: Service "public-nginx-ingress-controller" is invalid: spec.clusterIP: Invalid value: "": field is immutable && cannot patch "public-nginx-ingress-default-backend" with kind Service: Service "public-nginx-ingress-default-backend" is invalid: spec.clusterIP: Invalid value: "": field is immutable

  26. micseydel commented on Mar 18, 2020

    @micseydel

    Could someone clarify what the solution is here? I see that this got reopened then closed again 39 minutes later but I didn't see an obvious solution in this thread.

  27. DavidZisky commented on Mar 18, 2020

    @DavidZisky

    Could someone clarify what the solution is here? I see that this got reopened then closed again 39 minutes later but I didn't see an obvious solution in this thread.

    There is no solution yet but this one is promising and almost ready to implement:

    #7649

  28. bacongobbler commented on Mar 18, 2020

    @bacongobbler
    Member

    #7649 was merged this morning.

  29. DavidZisky commented on Mar 18, 2020

    @DavidZisky

    #7649 was merged this morning.

    Ohh, missed that ;) well, then answer to @micseydel question is in the first post of #7649 in Release Notes section

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions