diff options
Diffstat (limited to 'scripts/review_apps')
-rwxr-xr-x | scripts/review_apps/automated_cleanup.rb | 2 | ||||
-rw-r--r-- | scripts/review_apps/base-config.yaml | 2 | ||||
-rwxr-xr-x | scripts/review_apps/review-apps.sh | 44 |
3 files changed, 37 insertions, 11 deletions
diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb index 2d87c18d7d2..f459cb9c0ea 100755 --- a/scripts/review_apps/automated_cleanup.rb +++ b/scripts/review_apps/automated_cleanup.rb @@ -213,7 +213,7 @@ module ReviewApps gitlab.environments(project_path, per_page: DEPLOYMENTS_PER_PAGE, sort: 'desc', states: 'stopped', search: ENVIRONMENT_PREFIX[environment_type]).auto_paginate do |environment| next if skip_environment?(environment: environment, checked_environments: checked_environments, last_updated_threshold: last_updated_threshold, environment_type: environment_type) - yield environment if delete_environment(environment) + yield environment if delete_environment(environment) && block_given? checked_environments << environment.slug end diff --git a/scripts/review_apps/base-config.yaml b/scripts/review_apps/base-config.yaml index 0981aafec22..4d0f0ffec42 100644 --- a/scripts/review_apps/base-config.yaml +++ b/scripts/review_apps/base-config.yaml @@ -99,7 +99,7 @@ gitlab: cpu: 746m memory: 2809Mi limits: - cpu: 1300m + cpu: 1400m memory: 4214Mi minReplicas: 1 maxReplicas: 1 diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh index e185ed43e38..6a72b19c631 100755 --- a/scripts/review_apps/review-apps.sh +++ b/scripts/review_apps/review-apps.sh @@ -299,21 +299,21 @@ HELM_CMD=$(cat << EOF --set global.appConfig.sentry.dsn="${REVIEW_APPS_SENTRY_DSN}" \ --set global.appConfig.sentry.environment="review" \ --set gitlab.migrations.image.repository="${gitlab_toolbox_image_repository}" \ - --set gitlab.migrations.image.tag="${CI_COMMIT_REF_SLUG}" \ + --set gitlab.migrations.image.tag="${CI_COMMIT_SHA}" \ --set gitlab.gitaly.image.repository="${gitlab_gitaly_image_repository}" \ --set gitlab.gitaly.image.tag="${gitaly_image_tag}" \ --set gitlab.gitlab-shell.image.repository="${gitlab_shell_image_repository}" \ --set gitlab.gitlab-shell.image.tag="v${GITLAB_SHELL_VERSION}" \ --set gitlab.sidekiq.annotations.commit="${CI_COMMIT_SHORT_SHA}" \ --set gitlab.sidekiq.image.repository="${gitlab_sidekiq_image_repository}" \ - --set gitlab.sidekiq.image.tag="${CI_COMMIT_REF_SLUG}" \ + --set gitlab.sidekiq.image.tag="${CI_COMMIT_SHA}" \ --set gitlab.webservice.annotations.commit="${CI_COMMIT_SHORT_SHA}" \ --set gitlab.webservice.image.repository="${gitlab_webservice_image_repository}" \ - --set gitlab.webservice.image.tag="${CI_COMMIT_REF_SLUG}" \ + --set gitlab.webservice.image.tag="${CI_COMMIT_SHA}" \ --set gitlab.webservice.workhorse.image="${gitlab_workhorse_image_repository}" \ - --set gitlab.webservice.workhorse.tag="${CI_COMMIT_REF_SLUG}" \ + --set gitlab.webservice.workhorse.tag="${CI_COMMIT_SHA}" \ --set gitlab.toolbox.image.repository="${gitlab_toolbox_image_repository}" \ - --set gitlab.toolbox.image.tag="${CI_COMMIT_REF_SLUG}" + --set gitlab.toolbox.image.tag="${CI_COMMIT_SHA}" EOF ) @@ -362,20 +362,46 @@ function verify_deploy() { if [[ "${deployed}" == "true" ]]; then echoinfo "[$(date '+%H:%M:%S')] Review app is deployed to ${CI_ENVIRONMENT_URL}" - return 0 else echoerr "[$(date '+%H:%M:%S')] Review app is not available at ${CI_ENVIRONMENT_URL}: see the logs from cURL above for more details" return 1 fi } +# We need to be able to access the GitLab API to run this method. +# Since we are creating a personal access token in `disable_sign_ups`, +# This method should be executed after it. +function verify_commit_sha() { + local verify_success="false" + + for i in {1..60}; do # try for 2 minutes in case review-apps containers are restarting + echoinfo "[$(date '+%H:%M:%S')] Checking the correct commit is deployed in the review-app:" + echo "Expected commit sha: ${CI_COMMIT_SHA}" + + review_app_revision=$(curl --header "PRIVATE-TOKEN: ${REVIEW_APPS_ROOT_TOKEN}" "${CI_ENVIRONMENT_URL}/api/v4/metadata" | jq -r .revision) + echo "review-app revision: ${review_app_revision}" + + if [[ "${CI_COMMIT_SHA}" == "${review_app_revision}"* ]]; then + verify_success="true" + break + fi + + sleep 2 + done + + if [[ "${verify_success}" != "true" ]]; then + echoerr "[$(date '+%H:%M:%S')] Review app revision is not the same as the current commit!" + return 1 + fi + + return 0 +} + function display_deployment_debug() { local namespace="${CI_ENVIRONMENT_SLUG}" # Install dig to inspect DNS entries - # - # Silent install: see https://stackoverflow.com/a/52642167/1620195 - apt-get -qq update && apt-get -qq install -y dnsutils < /dev/null > /dev/null + apk add -q bind-tools echoinfo "[debugging data] Check review-app webservice DNS entry:" dig +short $(echo "${CI_ENVIRONMENT_URL}" | sed 's~http[s]*://~~g') |