Skip to content
Snippets Groups Projects
Commit e951dd9c authored by Thong Kuah's avatar Thong Kuah :speech_balloon:
Browse files

Workaround helm hooks not streaming logs

We use Helm hooks to run DB migration and initialization
but because there is no feature to [stream hook
logs](https://github.com/helm/helm/issues/2298), we use a function to
show logs from the `helm upgrade...` command.

`$CI_ENVIRONMENT_SLUG-db-initialize` and
`$CI_ENVIRONMENT_SLUG-db-migrate` pod selectors come from the
auto-deploy-app chart.
parent b86631a5
No related branches found
No related tags found
No related merge requests found
---
title: Show logs from Auto Devops DB initialize and migrate
merge_request: 22107
author:
type: changed
Loading
Loading
@@ -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" \
Loading
Loading
@@ -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" \
Loading
Loading
@@ -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" \
Loading
Loading
@@ -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}"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment