Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for customer deployments #4438

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 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,36 @@ pipelines:
jobs:
migrate:
elastic_profile_id: snuba
environment_variables:
SNUBA_SERVICE_NAME: snuba
tasks:
- script: |
##!/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/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 +262,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