Skip to content

helm upgrade after a failed helm upgrade does not pick up all new addition since last successful release #2346

Closed

Description

@kiich

Running helm/tiller v2.3.0

helm upgrade after a failed upgrade seems to not pick up all the changes I made in the deployment spec file.

Sequence of event is like this:
Using this deployment.yaml:

kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
        test: abcd
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

and do:
helm install --namespace temp --name temp /tmp/charts

which succeeds and create me deployment.
I then go and make few changes to the yaml, to make it fail, which looks like this:

kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
        env:
        - name: ENVTEST
          value: "HELLO"

and do:
helm upgrade --debug temp /tmp/charts

which fails with:

Error: UPGRADE FAILED: Deployment.extensions "nginx-deployment" is invalid: spec.template.metadata.labels: Invalid value: {"app":"nginx"}: `selector` does not match template `labels`

So i go and fix the issue in the yaml so it now looks like this:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
      test: abcd
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
        test: abcd
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
        env:
        - name: ENVTEST
          value: "HELLO"

and issue another helm upgrade which succeeds.
However, the deployment that resulted does not have the env section I wanted from the failed deploy.

Helm at the end reports the manifest does include the env section but kubectl get deployments does not so it does not match up.

helm manifest shows:

helm get manifest temp

---
# Source: temp/templates/deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
      test: abcd
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
        test: abcd
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
        env:
        - name: ENVTEST
          value: "HELLO"

kubectl get deployment after last success deployment:

spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
      test: abcd
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
        test: abcd
    spec:
      containers:
      - image: nginx:1.7.9
        imagePullPolicy: IfNotPresent
        name: nginx
        ports:
        - containerPort: 80
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext: {}
      terminationGracePeriodSeconds: 30

i.e. it does not have the env section.

Similar to #2333 and #2341

Activity

  1. kiich commented on Apr 28, 2017

    @kiich
    ContributorAuthor

    v2.3.1 reproduces same issue.

  2. technosophos commented on Apr 28, 2017

    @technosophos
    Member

    In this case, you must rollback before updating again in order to repair the broken selector.

  3. redbaron commented on Apr 29, 2017

    @redbaron
    Contributor

    If one must do something not to break Helm, then Helm must refuse any other actions or do it itself. Silently accepting updates and reporting success is very confusing and dangerous.

    In this case Helm should either do autorollback of any failed release or refuse future upgrades until operator does it manually

  4. jrnt30 commented on May 11, 2017

    @jrnt30

    This is especially painful when using stateful sets where there were changes to labels or something along those lines.

    We first attempted to deploy the new version of the chart, which failed because we had made changes to something other than the replicas in the stateful set. To get around this, we deleted the stateful set and then redeployed, but realized our changes were not present (because of this issue).

    Rolling back was not available because the upgrade had recreated the statefulset but left everything else on the old version.

  5. tuannvm commented on Aug 2, 2017

    @tuannvm

    2.5.1 has a same issue.
    I did need to manually delete my deployment and run helm upgrade again to fix that.

  6. burdiyan commented on Sep 11, 2017

    @burdiyan
    Contributor

    That's very annoying issue indeed.

  7. bacongobbler commented on Nov 7, 2017

    @bacongobbler
    Member

    this should be fixed via #3097, but please let me know if it isn't.

  8. kiich commented on Nov 8, 2017

    @kiich
    ContributorAuthor

    Awesome to hear this! Thanks for the great work!

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