GitLab CI/CD Review App Orphan Cleanup & Cost Control Prompt
Stop review-app environments from leaking namespaces, DNS records, and cloud cost after MRs are merged or abandoned by hardening stop jobs and TTLs.
- Target user
- Platform engineers running per-MR review apps
- Difficulty
- Intermediate
- Tools
- Claude, Copilot
The prompt
You are a senior platform engineer who specializes in GitLab review app lifecycle management. I will provide: - My deploy job with `environment:name` / `environment:url` for review apps - My current `stop` job (or absence of one) - Where review apps run (Kubernetes namespace, ephemeral cluster, VMs) - Symptoms (orphaned namespaces, rising cloud bill, stale DNS) Your job: 1. **Diagnose leaks** — explain why `on_stop` jobs fail to run (force-pushed MRs, deleted branches, failed teardown) and where orphans accumulate. 2. **Robust teardown** — author paired deploy + stop jobs using `environment:on_stop`, `environment:action: stop`, and `auto_stop_in` so idle environments self-expire. 3. **Namespace hygiene** — ensure the stop job deletes the namespace/release and DNS even when the source branch is gone (use `rules:if` on `merge_request_event`/branch deletion). 4. **Sweeper** — add a `scheduled` reaper job that lists and deletes environments past their TTL via the Environments API. 5. **Cost guardrail** — cap concurrent review apps via `resource_group` or quotas. 6. **Verify** — confirm environments transition to "stopped" and resources are gone. Output as: (a) deploy + stop job YAML, (b) the scheduled reaper job, (c) `auto_stop_in` config, (d) an orphan-audit checklist. Flag any teardown that could delete a shared or production namespace, and scope deletes to the review-app prefix only.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
GitLab CI/CD Conditional Deploy & Environment Rules Design Prompt
Design rules: and workflow: logic for environment-aware deploys so the right job runs per branch, tag, and trigger source — auto-deploy to staging, manual gate to prod, skip on docs-only changes — without duplicate or stuck pipelines.
-
GitLab CI/CD environment:kubernetes Namespace Binding Prompt
Bind a GitLab environment to a specific Kubernetes cluster and namespace via the GitLab agent so the environment page shows live pods, logs, and a working terminal — instead of an environment that's just a label with a URL.
-
GitLab CI/CD environment:auto_stop_in Ephemeral Cleanup Prompt
Auto-expire and tear down ephemeral environments using environment:auto_stop_in and on_stop jobs, so review apps and dynamic stacks don't leak cost or orphaned resources.
-
GitLab CI/CD before_script to extends Refactor Prompt
Refactor sprawling, duplicated before_script and inline shell across jobs into reusable hidden jobs, extends, and !reference so setup logic is defined once, tested, and consistent across the pipeline.
More GitLab CI/CD prompts & error guides
Browse every GitLab CI/CD prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.