Skip to content

fix(release): update the deployment script#138

Open
Ayush8923 wants to merge 2 commits into
mainfrom
feat/update-deployment-script
Open

fix(release): update the deployment script#138
Ayush8923 wants to merge 2 commits into
mainfrom
feat/update-deployment-script

Conversation

@Ayush8923

@Ayush8923 Ayush8923 commented Jul 21, 2026

Copy link
Copy Markdown

Summary

The EC2 hosts running staging and production were repeatedly filling up their EBS volumes. The culprit was BuildKit build cache: every deploy runs docker compose build, which writes a fresh set of cache layers, and nothing ever reclaimed them. The existing docker image prune -f only removes dangling images — it does not touch build cache, so the cache grew unbounded until deploys started failing on "no space left on device".

This PR appends docker builder prune -af to the end of the deploy command chain in both workflows:

  1. .github/workflows/cd-staging.yml
  2. .github/workflows/cd-production.yml

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The deployment workflows add Docker BuildKit cleanup after image pruning. The PII analysis notebook reformats markdown, imports, validator construction, and DataFrame displays without changing validation or metric behavior.

Changes

Deployment Docker cleanup

Layer / File(s) Summary
Remote Docker cleanup commands
.github/workflows/cd-production.yml, .github/workflows/cd-staging.yml
SSM deployment commands now run docker builder prune -af after docker image prune -f.

PII notebook formatting

Layer / File(s) Summary
PII analysis presentation updates
backend/notebooks/analysis-pii.py
Markdown cells, imports, validator construction, and DataFrame column displays are reformatted while preserving existing content and behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: akhileshnegi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: updating deployment scripts/workflows to add BuildKit pruning.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/update-deployment-script

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ayush8923 Ayush8923 changed the title fix(release): update the release script fix(release): update the deployment script Jul 21, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this PR only includes formatting-related CI fixes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/cd-production.yml:
- Line 34: Update the SSM deployment commands in
.github/workflows/cd-production.yml line 34 and .github/workflows/cd-staging.yml
line 33 to prevent docker builder prune -af from exceeding the workflow’s
polling window: either extend the associated SSM wait/poll duration beyond five
minutes or cap the prune step while preserving successful deployment completion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98b462b6-e45a-4071-b70c-9cb16ce2a0b7

📥 Commits

Reviewing files that changed from the base of the PR and between b6ef0c8 and ad915f9.

📒 Files selected for processing (3)
  • .github/workflows/cd-production.yml
  • .github/workflows/cd-staging.yml
  • backend/notebooks/analysis-pii.py

BUILD_DIRECTORY: ${{ secrets.BUILD_DIRECTORY }}
run: |
DEPLOY_CMD="cd ${BUILD_DIRECTORY} && git fetch --tags origin && git checkout --force ${{ github.sha }} && docker compose build && docker compose run --rm --entrypoint '' backend uv run --frozen alembic upgrade head && docker compose up -d --remove-orphans && docker image prune -f"
DEPLOY_CMD="cd ${BUILD_DIRECTORY} && git fetch --tags origin && git checkout --force ${{ github.sha }} && docker compose build && docker compose run --rm --entrypoint '' backend uv run --frozen alembic upgrade head && docker compose up -d --remove-orphans && docker image prune -f && docker builder prune -af"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in .github/workflows/cd-production.yml .github/workflows/cd-staging.yml; do
  echo "===== $f ====="
  nl -ba "$f" | sed -n '1,220p'
  echo
done

echo "===== search for SSM polling / timeout logic ====="
rg -n "wait|poll|timeout|ssm|builder prune|docker builder prune|docker image prune|DEPLOY_CMD" .github/workflows . -g '!**/node_modules/**'

Repository: ProjectTech4DevAI/kaapi-guardrails

Length of output: 260


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in .github/workflows/cd-production.yml .github/workflows/cd-staging.yml; do
  echo "===== $f ====="
  cat -n "$f" | sed -n '1,220p'
  echo
done

echo "===== search for polling / timeout logic ====="
rg -n "wait|poll|timeout|ssm|builder prune|docker builder prune|docker image prune|DEPLOY_CMD|send-command|get-command-invocation" .github/workflows . -g '!**/node_modules/**'

Repository: ProjectTech4DevAI/kaapi-guardrails

Length of output: 15127


🌐 Web query:

AWS SSM send-command get-command-invocation status poll timeout default command continues after client stops polling

💡 Result:

When you use AWS Systems Manager (SSM) Run Command, the process is asynchronous [1]. Stopping your client-side polling of get-command-invocation has no effect on the execution of the command on the managed node [1]. Key points regarding this behavior: 1. Asynchronous Execution: The send-command API initiates the command and returns a command ID, but it does not wait for the command to finish [1]. The command continues to run independently on the target instance regardless of what happens to the client that issued it [1][2]. 2. Polling vs. Execution: get-command-invocation is simply a mechanism to query the current status and output of a command that is already running or has already completed on the managed node [3][4]. Your client-side polling loop (or the CLI/SDK waiters) is only responsible for observing the state; it does not control the command's lifecycle [1][5][6]. 3. Command Timeouts: The lifecycle of the command is governed by parameters defined during the send-command call, specifically TimeoutSeconds (for delivery) and, if defined in the SSM document, Execution Timeout [2][7]. If these limits are reached, the SSM Agent on the managed node will terminate the execution and report the status as DeliveryTimedOut or ExecutionTimedOut, even if your client has stopped polling entirely [2][3]. In summary, the command on the target node is completely decoupled from your polling client. It will continue to execute until it finishes, reaches a terminal state (such as Success, Failed, or TimedOut), or is explicitly cancelled by another call to the cancel-command API [2][3].

Citations:


Extend the SSM wait window or cap the prune step.

docker builder prune -af runs inside the SSM command, but both workflows only poll for about 5 minutes (20 × 15s). If cleanup runs longer, the GitHub job fails while the remote command may still finish successfully, which creates false deployment failures and encourages unsafe retries.

  • .github/workflows/cd-production.yml#L34
  • .github/workflows/cd-staging.yml#L33
📍 Affects 2 files
  • .github/workflows/cd-production.yml#L34-L34 (this comment)
  • .github/workflows/cd-staging.yml#L33-L33
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/cd-production.yml at line 34, Update the SSM deployment
commands in .github/workflows/cd-production.yml line 34 and
.github/workflows/cd-staging.yml line 33 to prevent docker builder prune -af
from exceeding the workflow’s polling window: either extend the associated SSM
wait/poll duration beyond five minutes or cap the prune step while preserving
successful deployment completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant