diff options
-rw-r--r-- | changelogs/unreleased/52197-show-db-hook-logs.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml | 24 |
2 files changed, 26 insertions, 3 deletions
diff --git a/changelogs/unreleased/52197-show-db-hook-logs.yml b/changelogs/unreleased/52197-show-db-hook-logs.yml new file mode 100644 index 00000000000..a6fa7664623 --- /dev/null +++ b/changelogs/unreleased/52197-show-db-hook-logs.yml @@ -0,0 +1,5 @@ +--- +title: Show logs from Auto Devops DB initialize and migrate +merge_request: 22107 +author: +type: changed diff --git a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml index 72547c1b407..b4308a61763 100644 --- a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml @@ -625,7 +625,7 @@ rollout 100%: fi if [[ -n "$DB_INITIALIZE" && -z "$(helm ls -q "^$name$")" ]]; then - helm upgrade --install \ + initialize_logs helm upgrade --install \ --wait \ --set service.enabled="$service_enabled" \ --set releaseOverride="$CI_ENVIRONMENT_SLUG" \ @@ -647,7 +647,7 @@ rollout 100%: "$name" \ chart/ - helm upgrade --reuse-values \ + migrate_logs helm upgrade --reuse-values \ --wait \ --set application.initializeCommand="" \ --set application.migrateCommand="$DB_MIGRATE" \ @@ -655,7 +655,7 @@ rollout 100%: "$name" \ chart/ else - helm upgrade --install \ + migrate_logs helm upgrade --install \ --wait \ --set service.enabled="$service_enabled" \ --set releaseOverride="$CI_ENVIRONMENT_SLUG" \ @@ -681,6 +681,24 @@ rollout 100%: kubectl rollout status -n "$KUBE_NAMESPACE" -w "deployment/$name" } + function initialize_logs() { + if "$@"; then + if [[ -n "$DB_INITIALIZE" ]]; then kubectl logs -n "$KUBE_NAMESPACE" -l "job-name=$CI_ENVIRONMENT_SLUG-db-initialize"; fi + else + if [[ -n "$DB_INITIALIZE" ]]; then kubectl logs -n "$KUBE_NAMESPACE" -l "job-name=$CI_ENVIRONMENT_SLUG-db-initialize"; fi + exit 1 + fi + } + + function migrate_logs() { + if "$@"; then + if [[ -n "$DB_MIGRATE" ]]; then kubectl logs -n "$KUBE_NAMESPACE" -l "job-name=$CI_ENVIRONMENT_SLUG-db-migrate"; fi + else + if [[ -n "$DB_MIGRATE" ]]; then kubectl logs -n "$KUBE_NAMESPACE" -l "job-name=$CI_ENVIRONMENT_SLUG-db-migrate"; fi + exit 1 + fi + } + function scale() { track="${1-stable}" percentage="${2-100}" |