Skip to content

Commit d41b67b

Browse files
authored
ci(gocd): Skip canary stage in regions without canary (#213)
Follow-up to #209. The gocd pipelines unconditionally apply the canary stage, even in regions that do not have canary deployments. This succeeds instantly because no deployment is found, but introduces unnecessary wait time. With this change, we conditionally emit the canary stage only if a region uses canary deployments.
1 parent 7c1e9c6 commit d41b67b

File tree

1 file changed

+42
-34
lines changed

1 file changed

+42
-34
lines changed

gocd/templates/pipelines/objectstore.libsonnet

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,51 @@
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.',
4+
// NOTE: Sync with objectstore-k8s in getsentry/ops.
5+
local region_has_canary(region) =
6+
region == 'de' || region == 'us';
7+
8+
local deploy_canary(region) =
9+
if region_has_canary(region) then
10+
[
11+
{
12+
'deploy-canary': {
13+
fetch_materials: true,
14+
jobs: {
15+
create_sentry_release: {
16+
environment_variables: {
17+
SENTRY_ORG: 'sentry',
18+
SENTRY_PROJECT: 'objectstore',
19+
SENTRY_AUTH_TOKEN: '{{SECRET:[devinfra-sentryio][token]}}',
20+
SENTRY_ENVIRONMENT: region + '-canary',
21+
},
22+
timeout: 60,
23+
elastic_profile_id: 'objectstore',
24+
tasks: [
25+
gocdtasks.script(importstr '../bash/create-sentry-release.sh'),
26+
],
27+
},
28+
deploy: {
29+
timeout: 300,
30+
elastic_profile_id: 'objectstore',
31+
environment_variables: {
32+
K8S_ENVIRONMENT: 'canary',
33+
PAUSE_MESSAGE: 'Pausing pipeline due to canary failure.',
34+
},
35+
tasks: [
36+
gocdtasks.script(importstr '../bash/deploy.sh'),
37+
gocdtasks.script(importstr '../bash/wait-canary.sh'),
38+
// TODO: Add sentry error checks
39+
// TODO: Add datadog monitors
40+
utils.pause_on_failure(),
41+
],
42+
},
2843
},
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-
],
3644
},
3745
},
38-
},
39-
},
40-
];
46+
]
47+
else
48+
[];
4149

4250
local deploy_primary(region) = [
4351
{

0 commit comments

Comments
 (0)