Skip to content

Commit 3f0b9db

Browse files
authored
ci(gocd): Add canary deployments (#209)
Adds canary deployments that have to run for 300 seconds before proceeding with the full deploy. The pipeline automatically pauses on failure.
1 parent 5e0370c commit 3f0b9db

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

gocd/templates/bash/deploy.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ eval $(regions-project-env-vars --region="${SENTRY_REGION}")
44

55
/devinfra/scripts/get-cluster-credentials
66

7+
LABEL_SELECTOR="service=objectstore"
8+
if [[ -n "${K8S_ENVIRONMENT:-}" ]]; then
9+
LABEL_SELECTOR="$LABEL_SELECTOR,environment=$K8S_ENVIRONMENT"
10+
fi
11+
712
k8s-deploy \
8-
--label-selector="service=objectstore" \
9-
--image="us-docker.pkg.dev/sentryio/objectstore-mr/image:${GO_REVISION_OBJECTSTORE_REPO}" \
13+
--label-selector="$LABEL_SELECTOR" \
14+
--image="us-docker.pkg.dev/sentryio/objectstore-mr/image:$GO_REVISION_OBJECTSTORE_REPO" \
1015
--container-name="objectstore"

gocd/templates/bash/wait-canary.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Wait for 5 minutes
4+
sleep 300

gocd/templates/pipelines/objectstore.libsonnet

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
11
local utils = import '../libs/utils.libsonnet';
22
local gocdtasks = import 'github.com/getsentry/gocd-jsonnet/libs/gocd-tasks.libsonnet';
33

4+
local deploy_canary(region) = [
5+
{
6+
'deploy-canary': {
7+
fetch_materials: true,
8+
jobs: {
9+
create_sentry_release: {
10+
environment_variables: {
11+
SENTRY_ORG: 'sentry',
12+
SENTRY_PROJECT: 'objectstore',
13+
SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}',
14+
SENTRY_ENVIRONMENT: region + '-canary',
15+
},
16+
timeout: 60,
17+
elastic_profile_id: 'objectstore',
18+
tasks: [
19+
gocdtasks.script(importstr '../bash/create-sentry-release.sh'),
20+
],
21+
},
22+
deploy: {
23+
timeout: 300,
24+
elastic_profile_id: 'objectstore',
25+
environment_variables: {
26+
K8S_ENVIRONMENT: 'canary',
27+
PAUSE_MESSAGE: 'Pausing pipeline due to canary failure.',
28+
},
29+
tasks: [
30+
gocdtasks.script(importstr '../bash/deploy.sh'),
31+
gocdtasks.script(importstr '../bash/wait-canary.sh'),
32+
// TODO: Add sentry error checks
33+
// TODO: Add datadog monitors
34+
utils.pause_on_failure(),
35+
],
36+
},
37+
},
38+
},
39+
},
40+
];
41+
442
local deploy_primary(region) = [
543
{
644
'deploy-primary': {
@@ -45,5 +83,5 @@ function(region) {
4583
destination: 'objectstore',
4684
},
4785
},
48-
stages: utils.github_checks() + deploy_primary(region),
86+
stages: utils.github_checks() + deploy_canary(region) + deploy_primary(region),
4987
}

0 commit comments

Comments
 (0)