Skip to content
Open
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
11 changes: 9 additions & 2 deletions gocd/templates/bash/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

eval $(regions-project-env-vars --region="${SENTRY_REGION}")

IMAGE="us-central1-docker.pkg.dev/sentryio/chartcuterie/image:${GO_REVISION_CHARTCUTERIE_REPO}"

/devinfra/scripts/get-cluster-credentials \
&& k8s-deploy \
--label-selector="${LABEL_SELECTOR}" \
--image="us-central1-docker.pkg.dev/sentryio/chartcuterie/image:${GO_REVISION_CHARTCUTERIE_REPO}" \
--container-name="chartcuterie"
--image="${IMAGE}" \
--container-name="chartcuterie" \
&& materialized-ops-set-image \
--service="chartcuterie" \
--label-selector="${LABEL_SELECTOR}" \
--container-name="chartcuterie" \
--image="${IMAGE}"
Comment on lines +12 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The materialized-ops-set-image command runs unconditionally in a shared script, causing it to execute during canary deployments, which may be unintended.
Severity: MEDIUM

Suggested Fix

Add conditional logic to deploy.sh to ensure materialized-ops-set-image only executes during the primary deployment. This can be done by checking an environment variable that distinguishes between canary and primary stages before invoking the command.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: gocd/templates/bash/deploy.sh#L12-L16

Potential issue: The `deploy.sh` script is shared between `deploy-canary` and
`deploy-primary` stages. The newly added `materialized-ops-set-image` command runs
unconditionally in both. This causes it to execute during canary deployments with a
canary-specific `LABEL_SELECTOR` (`'service=chartcuterie,env=canary'`), which may be
unintended. The expected behavior is often for such tracking commands to run only during
the primary deployment. This could lead to incorrect or duplicate deployment records in
the `materialized-ops` system, potentially complicating deployment monitoring and
rollbacks.

Did we get this right? 👍 / 👎 to inform future reviews.

Loading