Commit a4a726af authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

fix: Use --atomic flag for deployments

parent af0c7a1b
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -257,6 +257,33 @@ test-deploy:
    - helm get values production --output json | grep "postgres://user:testing-password@production-postgres:5432/production"
    - ./test/verify-deployment-database production production-postgres

test-deploy-atomic:
  extends: test-deploy
  variables:
    POSTGRES_ENABLED: "false"
    KUBE_INGRESS_BASE_DOMAIN: ""
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    - auto-deploy deploy && exit 1 || echo "First deployment failed as expected"
    # second deploy should succeed
    - export KUBE_INGRESS_BASE_DOMAIN=example.com
    - auto-deploy deploy

test-deploy-non-atomic:
  extends: test-deploy
  variables:
    POSTGRES_ENABLED: "false"
    KUBE_INGRESS_BASE_DOMAIN: ""
    AUTO_DEVOPS_ATOMIC_RELEASE: "false"
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    - auto-deploy deploy && exit 1 || echo "First deployment failed as expected"
    # second deploy should also fail because the first release wasn't fully rolled back
    - export KUBE_INGRESS_BASE_DOMAIN=example.com
    - auto-deploy deploy && exit 1 || echo "Second release failed as expected"

test-deploy-postgresql-beta:
  extends: test-deploy
  variables:
+7 −0
Original line number Diff line number Diff line
@@ -208,10 +208,16 @@ function deploy() {
    echo "No helm values file found at ${helm_values_file@Q}"
  fi

  local atomic_flag=()
  if [[ "$AUTO_DEVOPS_ATOMIC_RELEASE" != "false" ]]; then
    atomic_flag=('--atomic')
  fi

  if [[ -n "$DB_INITIALIZE" && -z "$(helm ls -q "^$stable_name$")" ]]; then
    echo "Initializing service URL and database. No deployment will be created"
    # shellcheck disable=SC2086 # HELM_UPGRADE_EXTRA_ARGS -- double quote variables to prevent globbing
    helm upgrade --install \
      "${atomic_flag[@]}" \
      --wait \
      --set gitlab.app="$CI_PROJECT_PATH_SLUG" \
      --set gitlab.env="$CI_ENVIRONMENT_SLUG" \
@@ -249,6 +255,7 @@ function deploy() {
  echo "Deploying new $track release..."
  # shellcheck disable=SC2086 # HELM_UPGRADE_EXTRA_ARGS -- double quote variables to prevent globbing
  helm upgrade --install \
    "${atomic_flag[@]}" \
    --wait \
    --set gitlab.app="$CI_PROJECT_PATH_SLUG" \
    --set gitlab.env="$CI_ENVIRONMENT_SLUG" \