helm-controller icon indicating copy to clipboard operation
helm-controller copied to clipboard

Edit CRD Causes Errors

Open luthermonson opened this issue 6 years ago • 2 comments

If you add a CRD like the following

apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
  name: traefik-test
  namespace: kube-system
spec:
  chart: stable/traefik
  version: 1.64.0
  set:
    rbac.enabled: "true"
    ssl.enabled: "true"

let the helm jobs finish and you will have a new traefik pod. now edit the CR and change the version to 1.65.0. The onchange comes through and it tries to spin up a job but since the job already exists from the previous run it will try to rewrite the existing one and some job fields are immutable and you will get something like the following:

E0716 12:58:30.843044       1 controller.go:118] error syncing 'helm-controller/grafana': handler helm-controller: failed to update helm-controller/helm-install-grafana batch/v1, Kind=Job for helm-controller helm-controller/grafana: Job.batch "helm-install-grafana" is invalid: spec.template: Invalid value: <<<large blob of job data>>>  field is immutable, requeuing

need to handle edits a bit nicer and figure out how to do official upgrades to charts.

luthermonson avatar Jul 19 '19 21:07 luthermonson

We'd like to migrate from using Terraform Helm provider to using this controller but unfortunately can't move forward until chart version upgrades work.

Happy to contribute a pull request to fix the immutable field issue. However, after a few hours spent reading through the code and trying various changes it seems the fix needs to be made in the wrangler codebase. Initial thoughts were that Wrangler needs to support Kubernetes API patch operations.

sacreman avatar Jul 25 '19 00:07 sacreman

I have done little bit more digging and found that somewhere in the library adding NO_PROXY env variable, not the one defined in here https://github.com/rancher/helm-controller/blob/master/pkg/helm/controller.go#L334. This env var is added even before helm controller properly started. So the next time controller trying to update, if the env doesn't have NO_PROXY setup, patch operation is trying to remove that from env.

"containers": [
    {
        "$setElementOrder/env": [
            {
                "name": "NAME"
            },
            {
                "name": "VERSION"
            },
            {
                "name": "REPO"
            },
            {
                "name": "VALUES_HASH"
            }
        ],
        "env": [
            {
                "$patch": "delete",
                "name": "NO_PROXY"
            }
        ],
        "name": "helm"
    }
]
}
}
}
}"

gamunu avatar Jul 27 '19 09:07 gamunu