chore(ci): wait for Grafana Cloud readiness before dashboard provisioning#320
Conversation
…ning Grafana Cloud free-tier instances sleep when idle and return 503 "Your instance is loading" when first accessed. Add a readiness poll (up to 5 minutes) against /api/health before pushing the dashboard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: ea465215ea30
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdded a GitHub Actions workflow step ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability of the staging deployment workflow by adding a Grafana Cloud readiness check to handle free-tier “sleep/warm-up” behavior before attempting dashboard provisioning.
Changes:
- Adds a polling step (up to 5 minutes) that waits for Grafana Cloud to return HTTP 200 on
/api/health. - Ensures the “Push dashboard to Grafana Cloud” step runs only after Grafana is responsive.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/deploy-staging.yml (1)
514-516: Fail fast on missing Grafana env vars.This step should validate required env vars up front; otherwise it retries for minutes on a configuration error.
💡 Proposed fix (guard clauses)
set -euo pipefail + : "${GRAFANA_URL:?GRAFANA_URL is required}" + : "${GRAFANA_API_KEY:?GRAFANA_API_KEY is required}" GRAFANA_URL="${GRAFANA_URL%/}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/deploy-staging.yml around lines 514 - 516, Add upfront guard clauses after "set -euo pipefail" to validate required Grafana environment variables (e.g. GRAFANA_URL and GRAFANA_API_KEY) before entering retry logic; check that GRAFANA_URL is non-empty (after the existing GRAFANA_URL="${GRAFANA_URL%/}" normalization) and that GRAFANA_API_KEY (or any other required var) is set, and if any are missing emit a clear error to stderr and exit non-zero immediately (avoiding long MAX_ATTEMPTS retries). Ensure messages reference the variable names so the failure is actionable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/deploy-staging.yml:
- Around line 518-531: The retry loop uses a fixed MAX_ATTEMPTS which can exceed
a 5-minute wall-clock limit because each curl has its own timeout and there's
sleep; change the loop to enforce a deadline-based timeout instead: capture a
start time (or compute a deadline = now + 300), replace the for ((i=1...)) loop
with a loop that checks elapsed time against 300 seconds (or compares now to
deadline) and increments attempt counter only for logging, run the curl + sleep
until either HTTP 200 or elapsed >= 300, and update the final error/log to
report that Grafana did not become ready after the 5-minute deadline (use the
same variables like HTTP_CODE, INTERVAL, MAX_ATTEMPTS only for logging as
needed).
---
Nitpick comments:
In @.github/workflows/deploy-staging.yml:
- Around line 514-516: Add upfront guard clauses after "set -euo pipefail" to
validate required Grafana environment variables (e.g. GRAFANA_URL and
GRAFANA_API_KEY) before entering retry logic; check that GRAFANA_URL is
non-empty (after the existing GRAFANA_URL="${GRAFANA_URL%/}" normalization) and
that GRAFANA_API_KEY (or any other required var) is set, and if any are missing
emit a clear error to stderr and exit non-zero immediately (avoiding long
MAX_ATTEMPTS retries). Ensure messages reference the variable names so the
failure is actionable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6fd139d9-1814-4244-a2c0-53f8fd13ae33
📒 Files selected for processing (1)
.github/workflows/deploy-staging.yml
Address PR review feedback: - Validate GRAFANA_URL and GRAFANA_API_KEY are set before polling - Fail immediately on 401/403/404 instead of waiting full 5 minutes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 7195756b0244
Summary
503 "Your instance is loading"on first access/api/healthbefore pushing the dashboardProvision Grafana Dashboardjob in deploy-staging workflowTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit