CircleCI-Public / helm-orb

A CircleCI Orb to simplify deployments to Kubernetes using Helm.
MIT License
11 stars 26 forks source link

Failed Helm upgrade install when change orb from 1.2.0 to 3.0.1 #76

Closed petehouston closed 23 hours ago

petehouston commented 8 months ago

Orb version

3.0.1

What happened

I have many jobs using the orb Helm@1.2.0 without any problem

orbs:
  helm: circleci/helm@1.2.0

// ....step

      - helm/install-helm-client:
          version: v3.14.2
      - helm/upgrade-helm-chart:
            chart: ~/project/data-scheduler
            release-name: data-scheduler
            values-to-override: image.tag=${CIRCLE_BRANCH}-${CIRCLE_SHA1}
            namespace: scheduler-${CIRCLE_BRANCH}
            values: .circleci/environments/${CIRCLE_BRANCH}/values.yaml

I've tried to test with orb new version @3.0.1 to see if there is any differences

orbs:
  helm: circleci/helm@3.0.1

// ...steps

      - helm/install_helm_client:
          version: v3.14.2
      - helm/upgrade-helm-chart:
            chart: ~/project/data-scheduler
            release_name:data-scheduler
            values_to_override: image.tag=${CIRCLE_BRANCH}-${CIRCLE_SHA1}
            namespace: scheduler-${CIRCLE_BRANCH}
            values: .circleci/environments/${CIRCLE_BRANCH}/values.yaml

then it returns error saying:

+ helm upgrade --install ******************** '~/project/********************' --namespace=scheduler-dev --values .circleci/environments/dev/values.yaml --set image.tag=dev-6ab48824e5762a0ccaa8c2f743fc9f79ce914fe6
Error: repo ~ not found

Exited with code exit status 1

I was curious so I re-ran into SSH job, to my surprise, I was able to issue the command manually successfully. However, it doesn't work with the job execution helm/upgrade-helm-chart.

Expected behavior

It should execute normally without any issue.

Comments

As I dig the script, it seems to be issue over here:

https://github.com/CircleCI-Public/helm-orb/blob/master/src/scripts/upgrade_helm_chart.sh

https://github.com/CircleCI-Public/helm-orb/blob/master/src/scripts/upgrade_helm_chart.sh#L66-L69

HELM_STR_ADD_REPO="$(echo "${HELM_STR_ADD_REPO}" | circleci env subst)"

if [ -n "${HELM_STR_ADD_REPO}" ]; then
  helm repo add "${HELM_STR_RELEASE_NAME}" "${HELM_STR_ADD_REPO}"
  helm repo update
fi

I do not think it is a good idea to put helm repo update before executing install or upgrade. They are for different purposes.

My suggestions is to break out and create a new job for adding multiple repos, ex:

helm/repo_update:
    - repos: "URL1","URL2"...
marboledacci commented 1 month ago

Hi @petehouston the code you mention is only executed when add_repo is passed, by default it is empty. And I see you didn't pass anything, so this shouldn't be related to the problem you have. This looks like a problem looking for the directory, can you pass the path without using ~. I'm gonna look into this further, but I think in your case you could pass just data-scheduler