Skip to content

Helm is inconsistent about failed deployments #2437

Closed

Description

@jwkohnen

This is basically a generalized version of the bug #2257, possibly other filed issues and a failure mode that I've encountered today.

It seems that helm does not care if for some unknown class of reasons a deployment fails. Helm will report the failure but then happily false-successfully re-deploy the same chart, without changing the actual state but registering a new state in a history config map (revision).

There are two ways to trigger helm's schizophrenia:

  1. Helm detects wrong state when chart contains envFrom #2257
    1a. Install a chart that contains a property that is yet unknown to helm, e.g. envFrom before helm v2.4.0: true success
    1b. Upgrade the release with a change in its chart that may or may not be related to that property, thus triggering the patch code path: failure
    1c. Upgrade the release again without any change: the cluster is in an undefined state and helm lies about it. :(

  2. 2a. Install a chart that is both valid and fully supported by helm. My case includes a ClusterRoleBinding: deployment is successful, obviously.
    2b. Change the ClusterRoleBinding using an invalid {kind: ServiceAccount, subjects.name:}. Deployment fails as it should.
    2c. Deploy the same chart again w/o any changes since 2b. This deployment falsely succeeds and helm is in the same schizophrenic state as in case 1.

/cc @tback @jayme-github

Activity

  1. changed the title [-]Helm is schizophrenic about failed deployments[/-] [+]Helm is inconsistent about failed deployments[/+] on May 12, 2017
  2. rsanders commented on May 24, 2017

    @rsanders

    We are getting bitten by this several times a week.

  3. technosophos commented on May 24, 2017

    @technosophos
    Member

    By what, precisely?

  4. rsanders commented on May 24, 2017

    @rsanders

    IIUC, some variant of 2b. we see Helm/Tiller get out of sync with K8s actual state. It's not envFrom, and it's not silently immutable fields in Deployment or Daemonset. It has occurred in several different cases when the K8S API server rejecting a patches due to failed validations. Helm seems to barrel on assuming that the patch succeeded, and recording the desired state as actual.

    For example, from the Tiller log:

    2017/05/16 01:22:37 client.go:251: error updating the resource "service-proxy":
             Deployment.apps "service-proxy" is invalid: spec.template.spec.containers[0].ports[1].protocol: Unsupported value: "HTTP": supported values: TCP, UDP
    ...
    2017/05/16 01:22:38 release_server.go:329: warning: Upgrade "RELEASENAME" failed: Deployment.apps "service-proxy" is invalid: spec.template.spec.containers[0].ports[1].protocol: Unsupported value: "HTTP": supported values: TCP, UDP
    2017/05/16 01:22:38 storage.go:59: Updating "RELEASENAME" (v47) in storage
    2017/05/16 01:22:38 storage.go:51: Create release "RELEASENAME" (v48) in storage
    

    After that, there were some other changes -- in this case I believe to the "image" and "env" of one of the containers -- that didn't occur, but were apparently recorded as being successful. Future upgrades after correcting the protocol to 'TCP' did not update the image and env contents to the new values.

    I don't have a minimal test case put together yet, but I do have the full Tiller log and the "helm get" of the Tiller release configmaps from before and after the failure.

    This occurred with Tiller v2.4.1, Helm client v2.3.1 on K8S 1.6.3.

  5. rsanders commented on May 24, 2017

    @rsanders

    Perhaps I should comment instead on #2257?

  6. technosophos commented on May 24, 2017

    @technosophos
    Member

    Okay. Thanks. I'm currently looking into the following two options:

    1. If a release fails, don't allow an upgrade without first doing a rollback to a known-good version
    2. If a validation fails, see if we can avoid storing the new manifest (e.g. force a diff against the last known valid version). This one is harder than it sounds, and may just introduce another set of bugs.

    And perhaps there are some other options that I haven't thought of.

  7. rsanders commented on May 25, 2017

    @rsanders

    In our case, this issue mostly occurs during development. The errors happen, and then the developer re-upgrades the release (apparently) successfully after fixing the validation problem. Long after that original error, the disconnect between what the developer believes is running in the cluster and what is actually running continues, leading to a great deal of confusion.

    Option #1 seems like an unambiguous, low-risk improvement. A degraded state that forces the operator to explicitly resolve it with some extraordinary means would prevent all that confusion.

    It's too bad the K8S API doesn't have its own "dry run" mode for validation-only operations, or transactional batch mode.

  8. ahawkins commented on May 25, 2017

    @ahawkins
    Contributor

    We are also getting hit by something similar to this. Our helm upgrade fails for something like this:

             Deployment.extensions "efritin-efritin-image-service-thrift" is invalid: spec.template.metadata.labels: Invalid value: {"app":"efritin-efritin","chart":"efritin-0.1.0-rc6","component":"image_service","release":"efritin","source":
    "kviberg","stage":"production","tier":"thrift"}: `selector` does not match template `labels`
    

    Running helm upgrade again with the same chart and release "succeeds", but nothing changes on the K8s resources themselves. In our case all future upgrades are communicated incorrectly, so once the upgrade fails it seems that it cannot be correctly upgraded again.

  9. technosophos commented on May 25, 2017

    @technosophos
    Member

    This was discussed on the dev call at length this morning. We need to devise a repeatable case of this so that we can start writing test cases. If anyone has a minimal reproduction case, please point to it here.

    /cc @adamreese @seh

    See also #2341 - which is an approach I don't think will work because it will invert the problem (successful things will fail because a strategic merge will be run on the wrong version). But I could be wrong. :-)

  10. rsanders commented on May 26, 2017

    @rsanders
  11. added this to the Upcoming - Minor milestone on Aug 4, 2017
  12. blakebarnett commented on Aug 7, 2017

    @blakebarnett

    We see this very frequently also.

  13. jascott1 commented on Sep 12, 2017

    @jascott1
    Contributor

    @technosophos I confirm that the test chart illustrates the issue (thanks @rsanders). You are left with an innocent looking history that does not reveal revision 2 failed and the current release manifest (3) does not reflect the actual k8s manifest (1).

    REVISION	UPDATED                 	STATUS    	CHART          	DESCRIPTION
    1       	Mon Sep 11 17:31:48 2017	SUPERSEDED	helm-2437-1.0.0	Install complete
    2       	Mon Sep 11 17:31:53 2017	SUPERSEDED	helm-2437-1.0.0	Preparing upgrade
    3       	Mon Sep 11 17:32:00 2017	DEPLOYED  	helm-2437-1.0.0	Upgrade complete
    
  14. 2 remaining items

  15. blakebarnett commented on Oct 31, 2017

    @blakebarnett

    Yeah I couldn't find it earlier, but it's here: #2341

    There are various other issues and PRs that reference this problem also in different ways, here's a couple:
    #2333
    #2346

  16. thomastaylor312 commented on Nov 1, 2017

    @thomastaylor312
    Contributor
  17. added 3 commits that reference this issue on Nov 3, 2017
    7c73cb7
    7d7e97b
    82ef751
  18. jwkohnen commented on Nov 8, 2017

    @jwkohnen
    Author

    From #3097 (comment)

    The only edge case this may introduce is when a user deploys a release that initially fails then tries to upgrade to fix it, but if a chart is in that state it should be removed and re-deployed.

    That's not an edge case, though. It is an expected action path, especially in an environment where Helm is used in a CD pipeline, operated by non-k8s and non-helm experienced users (which is a point of having a CD). It is virtually impossible to explain this (again: to be expected) case of undefined and horribly misleading behavior to application developers.

    Helm in my opinion must detect a failed state and fail to upgrade from it (unless Helm can fix the state properly). I hope I am not too annoying by repetition, but the main point I am trying to make is: This is not an edge case. It is a major pain point. It renders Helm as the weakest link in any CD chain.

  19. bacongobbler commented on Nov 8, 2017

    @bacongobbler
    Member

    That is exactly what we are doing with this patch.

  20. jwkohnen commented on Nov 9, 2017

    @jwkohnen
    Author

    Are you saying that the now merged fix removes and re-deploys a chart if (edge case) a release initially failed and then a user tries to fix it by deploying a new release?

  21. added a commit that references this issue on Nov 14, 2017
    0647a7b
  22. chancez commented on Nov 17, 2017

    @chancez

    I am still hitting this issue with 2.7.2

  23. bacongobbler commented on Nov 17, 2017

    @bacongobbler
    Member

    @wjkohnen no.

    @chancez can you provide a test case we can use to reproduce the issue?

    A list of the usual suspects would be helpful to identify the root cause:

    • helm version
    • kubectl version
    • where the cluster was deployed
    • the commands/chart deployed causing the error
  24. chancez commented on Nov 20, 2017

    @chancez

    helm version is 2.7.2 and kubectl version is 1.8.0. Cluster was minikube v0.23.0 (k8s 1.8.0) but the chart isn't public/easy to pair down. It's just a helm upgrade on a previously failed release (previous release timed out with --wait) (doesn't matter if there have been successful previously or not).

    I'll see if i can come up with a simple reproduction, but might take some time as I'm switching back to 2.6.2 to work around this for now.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions