diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-19 15:06:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-19 15:06:24 +0000 |
commit | 88542a5e9613c8442a982e65ad5cf13eb33bc541 (patch) | |
tree | 11a65d86e623b443b8a2976cc93cff360e2da8a2 /scripts | |
parent | b570d73ecd31e2ca9cf8c2f1adb056edf2869477 (diff) | |
download | gitlab-ce-88542a5e9613c8442a982e65ad5cf13eb33bc541.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/prepare_build.sh | 34 | ||||
-rwxr-xr-x | scripts/review_apps/review-apps.sh | 30 | ||||
-rw-r--r-- | scripts/utils.sh | 10 |
3 files changed, 23 insertions, 51 deletions
diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 0950ec272a5..e80d752f09f 100644 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -16,37 +16,21 @@ retry gem install knapsack --no-document cp config/gitlab.yml.example config/gitlab.yml sed -i 's/bin_path: \/usr\/bin\/git/bin_path: \/usr\/local\/bin\/git/' config/gitlab.yml -# Determine the database by looking at the job name. -# This would make the default database postgresql. -if [[ "${CI_JOB_NAME#*mysql}" != "$CI_JOB_NAME" ]]; then - export GITLAB_DATABASE='mysql' -else - export GITLAB_DATABASE='postgresql' -fi - -cp config/database.yml.$GITLAB_DATABASE config/database.yml +cp config/database.yml.postgresql config/database.yml -if [ -f config/database_geo.yml.$GITLAB_DATABASE ]; then - cp config/database_geo.yml.$GITLAB_DATABASE config/database_geo.yml +if [ -f config/database_geo.yml.postgresql ]; then + cp config/database_geo.yml.postgresql config/database_geo.yml fi # Set user to a non-superuser to ensure we test permissions sed -i 's/username: root/username: gitlab/g' config/database.yml -if [ "$GITLAB_DATABASE" = 'postgresql' ]; then - sed -i 's/localhost/postgres/g' config/database.yml - sed -i 's/username: git/username: postgres/g' config/database.yml - - if [ -f config/database_geo.yml ]; then - sed -i 's/localhost/postgres/g' config/database_geo.yml - sed -i 's/username: git/username: postgres/g' config/database_geo.yml - fi -else # Assume it's mysql - sed -i 's/localhost/mysql/g' config/database.yml +sed -i 's/localhost/postgres/g' config/database.yml +sed -i 's/username: git/username: postgres/g' config/database.yml - if [ -f config/database_geo.yml ]; then - sed -i 's/localhost/mysql/g' config/database_geo.yml - fi +if [ -f config/database_geo.yml ]; then + sed -i 's/localhost/postgres/g' config/database_geo.yml + sed -i 's/username: git/username: postgres/g' config/database_geo.yml fi cp config/resque.yml.example config/resque.yml @@ -63,6 +47,6 @@ sed -i 's|url:.*$|url: redis://redis:6379/12|g' config/redis.shared_state.yml if [ "$SETUP_DB" != "false" ]; then setup_db -elif getent hosts postgres || getent hosts mysql; then +elif getent hosts postgres; then setup_db_user_only fi diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh index ed872783856..0842f7871ee 100755 --- a/scripts/review_apps/review-apps.sh +++ b/scripts/review_apps/review-apps.sh @@ -1,4 +1,5 @@ [[ "$TRACE" ]] && set -x +export TILLER_NAMESPACE="$KUBE_NAMESPACE" function deploy_exists() { local namespace="${1}" @@ -13,18 +14,16 @@ function deploy_exists() { } function previous_deploy_failed() { - local namespace="${1}" - local deploy="${2}" - + local deploy="${1}" echoinfo "Checking for previous deployment of ${deploy}" true - helm status --tiller-namespace "${namespace}" "${deploy}" >/dev/null 2>&1 + helm status "${deploy}" >/dev/null 2>&1 local status=$? # if `status` is `0`, deployment exists, has a status if [ $status -eq 0 ]; then echoinfo "Previous deployment found, checking status..." - deployment_status=$(helm status --tiller-namespace "${namespace}" "${deploy}" | grep ^STATUS | cut -d' ' -f2) + deployment_status=$(helm status "${deploy}" | grep ^STATUS | cut -d' ' -f2) echoinfo "Previous deployment state: ${deployment_status}" if [[ "$deployment_status" == "FAILED" || "$deployment_status" == "PENDING_UPGRADE" || "$deployment_status" == "PENDING_INSTALL" ]]; then status=0; @@ -38,17 +37,16 @@ function previous_deploy_failed() { } function delete_release() { - local namespace="${KUBE_NAMESPACE}" - local deploy="${CI_ENVIRONMENT_SLUG}" - - if [ -z "$deploy" ]; then + if [ -z "$CI_ENVIRONMENT_SLUG" ]; then echoerr "No release given, aborting the delete!" return fi - echoinfo "Deleting release '$deploy'..." true + local name="$CI_ENVIRONMENT_SLUG" + + echoinfo "Deleting release '$name'..." true - helm delete --purge --tiller-namespace "${namespace}" "${deploy}" + helm delete --purge "$name" } function delete_failed_release() { @@ -61,7 +59,7 @@ function delete_failed_release() { echoinfo "No Review App with ${CI_ENVIRONMENT_SLUG} is currently deployed." else # Cleanup and previous installs, as FAILED and PENDING_UPGRADE will cause errors with `upgrade` - if previous_deploy_failed "${KUBE_NAMESPACE}" "$CI_ENVIRONMENT_SLUG" ; then + if previous_deploy_failed "$CI_ENVIRONMENT_SLUG" ; then echoinfo "Review App deployment in bad state, cleaning up $CI_ENVIRONMENT_SLUG" delete_release else @@ -119,7 +117,6 @@ function ensure_namespace() { } function install_tiller() { - local TILLER_NAMESPACE="$KUBE_NAMESPACE" echoinfo "Checking deployment/tiller-deploy status in the ${TILLER_NAMESPACE} namespace..." true echoinfo "Initiating the Helm client..." @@ -134,12 +131,11 @@ function install_tiller() { --override "spec.template.spec.tolerations[0].key"="dedicated" \ --override "spec.template.spec.tolerations[0].operator"="Equal" \ --override "spec.template.spec.tolerations[0].value"="helm" \ - --override "spec.template.spec.tolerations[0].effect"="NoSchedule" \ - --tiller-namespace "${TILLER_NAMESPACE}" + --override "spec.template.spec.tolerations[0].effect"="NoSchedule" kubectl rollout status -n "$TILLER_NAMESPACE" -w "deployment/tiller-deploy" - if ! helm version --debug --tiller-namespace "${TILLER_NAMESPACE}"; then + if ! helm version --debug; then echo "Failed to init Tiller." return 1 fi @@ -151,7 +147,7 @@ function install_external_dns() { domain=$(echo "${REVIEW_APPS_DOMAIN}" | awk -F. '{printf "%s.%s", $(NF-1), $NF}') echoinfo "Installing external DNS for domain ${domain}..." true - if ! deploy_exists "${KUBE_NAMESPACE}" "${release_name}" || previous_deploy_failed "${KUBE_NAMESPACE}" "${release_name}" ; then + if ! deploy_exists "${KUBE_NAMESPACE}" "${release_name}" || previous_deploy_failed "${release_name}" ; then echoinfo "Installing external-dns Helm chart" helm repo update # Default requested: CPU => 0, memory => 0 diff --git a/scripts/utils.sh b/scripts/utils.sh index f0f08e2e1c5..83b7173e140 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -14,11 +14,7 @@ function retry() { } function setup_db_user_only() { - if [ "$GITLAB_DATABASE" = "postgresql" ]; then - source scripts/create_postgres_user.sh - else - source scripts/create_mysql_user.sh - fi + source scripts/create_postgres_user.sh } function setup_db() { @@ -26,10 +22,6 @@ function setup_db() { bundle exec rake db:drop db:create db:schema:load db:migrate - if [ "$GITLAB_DATABASE" = "mysql" ]; then - bundle exec rake add_limits_mysql - fi - bundle exec rake gitlab:db:setup_ee } |