Commit f60f73c1 authored by Thong Kuah's avatar Thong Kuah
Browse files

Merge branch 'only-delete-old-postgres-if-explicitly-requested' into 'master'

fix: Only delete old postgres if explicitly requested

See merge request gitlab-org/cluster-integration/auto-deploy-image!64
parents 7ba43a9d d727fea6
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -298,6 +298,39 @@ test-deploy-postgresql-beta:
    - helm get values production --output json | grep "postgres://user:testing-password@production-postgresql:5432/production"
    - ./test/verify-deployment-database production postgresql

test-deploy-does-not-delete-old-postgres-by-default:
  extends: test-deploy
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    # make sure old posgres deployment exists
    - export AUTO_DEVOPS_POSTGRES_CHANNEL=1
    - auto-deploy deploy
    - ./test/verify-deployment-database production production-postgres
    # test that the deploy job fails
    - export POSTGRES_VERSION='9.6.16'
    - export AUTO_DEVOPS_POSTGRES_CHANNEL=2
    - auto-deploy deploy && expected_error || failed_as_expected
    # assert that postgres still exists
    - ./test/verify-deployment-database production production-postgres

test-deploy-deletes-old-postgres-if-opt-in:
  extends: test-deploy
  script:
    - auto-deploy initialize_tiller
    - auto-deploy download_chart
    - export AUTO_DEVOPS_POSTGRES_CHANNEL=1
    # make sure old postgres deployment exists
    - auto-deploy deploy
    - ./test/verify-deployment-database production production-postgres
    # test that the deploy job succeeds
    - export POSTGRES_VERSION='9.6.16'
    - export AUTO_DEVOPS_POSTGRES_CHANNEL=2
    - export AUTO_DEVOPS_POSTGRES_DELETE_V1=1
    - auto-deploy deploy
    # test that the new postgres is up
    - ./test/verify-deployment-database production postgresql

test-deploy-canary:
  extends: test-deploy
  script:
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ ARG GLIBC_VERSION
COPY src/ build/

# Install Dependencies
RUN apk add --no-cache openssl curl tar gzip bash \
RUN apk add --no-cache openssl curl tar gzip bash jq \
  && curl -sSL -o /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
  && curl -sSL -O https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
  && apk add glibc-${GLIBC_VERSION}.apk \
+10 −3
Original line number Diff line number Diff line
@@ -134,8 +134,18 @@ function deploy() {
  local name
  name=$(deploy_name "$track")

  local stable_name
  stable_name=$(deploy_name stable)

  local old_postgres_already_enabled
  local old_postgres_enabled
  if [[ "$POSTGRES_ENABLED" == "true" && "$AUTO_DEVOPS_POSTGRES_CHANNEL" == "2" ]]; then
    old_postgres_already_enabled=$( (helm get values --output json "$stable_name" || echo '{}') | jq '.postgresql.enabled')
    if [[ -z "$AUTO_DEVOPS_POSTGRES_DELETE_V1" ]] && [[ "$old_postgres_already_enabled" == "true" ]]; then
      echo 'Detected an existing V1 PostgreSQL database that would have been deleted. To proceed and delete this V1 PostgreSQL database, set AUTO_DEVOPS_POSTGRES_DELETE_V1 to a non-empty value and redeploy.'
      exit 1
    fi

    install_postgresql

    # Do not install the older 0.7.1 postgresql sub-chart
@@ -147,9 +157,6 @@ function deploy() {
  local database_url
  database_url=$(auto_database_url)

  local stable_name
  stable_name=$(deploy_name stable)

  local image_repository
  local image_tag