Skip to content

Commit

Permalink
Add script for customer deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgauntseo-sentry committed Jun 28, 2023
1 parent ce7bc50 commit 7ede669
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 41 deletions.
40 changes: 26 additions & 14 deletions gocd/generated-pipelines/snuba-next-monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,30 @@ pipelines:
jobs:
migrate:
elastic_profile_id: snuba
environment_variables:
SNUBA_SERVICE_NAME: snuba
tasks:
- script: |
##!/bin/bash
eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel
/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-spawn-job.py \
--context="gke_${GCP_PROJECT}_${GKE_REGION}-${GKE_CLUSTER_ZONE}_${GKE_CLUSTER}" \
--label-selector="service=snuba-admin" \
--container-name="snuba-admin" \
"snuba-migrate" "us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- snuba migrations migrate -r complete -r partial
/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-bootstrap" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba bootstrap --force --no-migrate
/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations migrate --force
- plugin:
configuration:
id: script-executor
Expand All @@ -245,14 +256,15 @@ pipelines:
##!/bin/bash
eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel
/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-spawn-job.py \
--context="gke_${GCP_PROJECT}_${GKE_REGION}-${GKE_CLUSTER_ZONE}_${GKE_CLUSTER}" \
--label-selector="service=snuba-admin" \
--container-name="snuba-admin" \
"snuba-migrate-reverse" "us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- snuba migrations reverse-in-progress
/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate-reverse" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations reverse-in-progress
run_if: failed
timeout: 1200
- pipeline-complete:
Expand Down
31 changes: 18 additions & 13 deletions gocd/generated-pipelines/snuba-next-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,23 @@ pipelines:
jobs:
migrate:
elastic_profile_id: snuba
environment_variables:
SNUBA_SERVICE_NAME: snuba-admin
tasks:
- script: |
##!/bin/bash
eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel
/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-spawn-job.py \
/devinfra/scripts/k8s/k8s-spawn-job.py \
--context="gke_${GCP_PROJECT}_${GKE_REGION}-${GKE_CLUSTER_ZONE}_${GKE_CLUSTER}" \
--label-selector="service=snuba-admin" \
--container-name="snuba-admin" \
"snuba-migrate" "us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- snuba migrations migrate -r complete -r partial
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations migrate -r complete -r partial
- plugin:
configuration:
id: script-executor
Expand All @@ -245,14 +249,15 @@ pipelines:
##!/bin/bash
eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel
/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-spawn-job.py \
--context="gke_${GCP_PROJECT}_${GKE_REGION}-${GKE_CLUSTER_ZONE}_${GKE_CLUSTER}" \
--label-selector="service=snuba-admin" \
--container-name="snuba-admin" \
"snuba-migrate-reverse" "us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- snuba migrations reverse-in-progress
/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate-reverse" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations reverse-in-progress
run_if: failed
timeout: 1200
- pipeline-complete:
Expand Down
15 changes: 8 additions & 7 deletions gocd/templates/bash/migrate-reverse.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash

eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel

/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-spawn-job.py \
--context="gke_${GCP_PROJECT}_${GKE_REGION}-${GKE_CLUSTER_ZONE}_${GKE_CLUSTER}" \
--label-selector="service=snuba-admin" \
--container-name="snuba-admin" \
"snuba-migrate-reverse" "us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- snuba migrations reverse-in-progress
/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate-reverse" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations reverse-in-progress
26 changes: 26 additions & 0 deletions gocd/templates/bash/migrate-st.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# At the time of writing (2023-06-28) the single tenant deployments
# have been using a different migration process compared to the
# US deployment of snuba.
# This script should be merged with migrate.sh if we can figure
# out a common migration script for all regions.

eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel

/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-bootstrap" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba bootstrap --force --no-migrate

/devinfra/scripts/k8s/k8s-spawn-job.py \
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations migrate --force
14 changes: 8 additions & 6 deletions gocd/templates/bash/migrate.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash

eval $(/devinfra/scripts/regions/project_env_vars.py --region="${SENTRY_REGION}")
/devinfra/scripts/k8s/k8stunnel

/devinfra/scripts/k8s/k8stunnel \
&& /devinfra/scripts/k8s/k8s-spawn-job.py \
/devinfra/scripts/k8s/k8s-spawn-job.py \
--context="gke_${GCP_PROJECT}_${GKE_REGION}-${GKE_CLUSTER_ZONE}_${GKE_CLUSTER}" \
--label-selector="service=snuba-admin" \
--container-name="snuba-admin" \
"snuba-migrate" "us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- snuba migrations migrate -r complete -r partial
--label-selector="service=${SNUBA_SERVICE_NAME}" \
--container-name="${SNUBA_SERVICE_NAME}" \
"snuba-migrate" \
"us.gcr.io/sentryio/snuba:${GO_REVISION_SNUBA_REPO}" \
-- \
snuba migrations migrate -r complete -r partial
8 changes: 7 additions & 1 deletion gocd/templates/pipelines/snuba.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ function(region) {
migrate: {
timeout: 1200,
elastic_profile_id: 'snuba',
environment_variables: {
SNUBA_SERVICE_NAME: if region == 'monitor' || std.startsWith(region, 'customer-') then 'snuba' else 'snuba-admin',
},
tasks: [
gocdtasks.script(importstr '../bash/migrate.sh'),
if region == 'monitor' || std.startsWith(region, 'customer-') then
gocdtasks.script(importstr '../bash/migrate-st.sh')
else
gocdtasks.script(importstr '../bash/migrate.sh'),
{
plugin: {
options: gocdtasks.script(importstr '../bash/migrate-reverse.sh'),
Expand Down

0 comments on commit 7ede669

Please sign in to comment.