Skip to content

feat: add teardown option to toggle workflow - #36

Merged
ricardogr07 merged 4 commits into
mainfrom
feat/toggle-teardown
Jun 26, 2026
Merged

ricardogr07 merged 4 commits into
mainfrom
feat/toggle-teardown

Conversation

@ricardogr07

Copy link
Copy Markdown
Owner

Summary

  • Adds a teardown action that deletes the ACI container group and wipes both file shares (clipsmith-data, clipsmith-out), dropping Azure storage charges to near-zero during idle periods
  • Upgrades start to detect whether the container group exists: calls az container start for a stopped group, or re-creates it from clipsmith:latest after a teardown — no Deploy re-run needed
  • teardown reuses the active-run guard so it's blocked if a pipeline job is in progress

Cost impact

Resource stop teardown
ACI compute paused ✓ deleted ✓
Storage (data + clips) still charged wiped → ~$0 ✓
ACR images unchanged unchanged

Test plan

  • CI green (workflow is YAML-only, no Python/TS changes)
  • Manually trigger teardown and confirm ACI container group is deleted and file shares are empty
  • Manually trigger start after teardown and confirm container is re-created and API is healthy

Two bugs preventing clips from playing in the dashboard:

1. fileUrl used DIRECT (http://api-ip:8000) — browsers block loading
   HTTP media from an HTTPS Vercel page (mixed-content policy).
   Fix: route file downloads through the same-origin Next.js proxy.

2. The proxy read all responses with upstream.text(), which corrupts
   binary MP4 data. Fix: use arrayBuffer() so binary passes through intact.
Adds a third action — teardown — that deletes the ACI container group
and wipes both file shares (clipsmith-data, clipsmith-out) so Azure
storage charges drop to near-zero during idle periods.

Also upgrades start to detect whether the container group exists: it
calls az container start for an existing group, or re-creates it from
clipsmith:latest (same YAML as deploy.yml) after a teardown, making
toggle self-sufficient without a full Deploy re-run.
@ricardogr07
ricardogr07 merged commit 32caacf into main Jun 26, 2026
7 checks passed
@ricardogr07
ricardogr07 deleted the feat/toggle-teardown branch June 26, 2026 04:26

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 380e8cd9b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

runs = json.load(sys.stdin)
print(any(r['status'] in ('pending', 'running') for r in runs))
")
" 2>/dev/null || echo "False")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fail closed when the active-run check fails

This fallback turns any /runs failure—HTTP error, transient DNS/network issue, or malformed JSON—into ACTIVE=False. For teardown, that means a temporary inability to read the run list can bypass the only guard and the following steps can delete the ACI and wipe both file shares while a pending/running job still exists; this should abort unless the workflow has independently proven the container is absent or stopped.

Useful? React with 👍 / 👎.

az container delete \
--resource-group ${{ secrets.RESOURCE_GROUP }} \
--name ${{ secrets.ACI_NAME_DEV }} \
--yes 2>/dev/null || echo "Container group not found or already deleted."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not continue teardown after delete failures

The || echo handles every non-zero az container delete result as if the group were already gone. If Azure returns a permission, resource-lock, conflict, or transient failure while the storage key is still valid, the workflow continues into the share-wipe steps with the container group potentially still alive, risking deletion of the DB/output files under a running service; only a verified not-found case should be ignored.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant