add delete_alert_pod action, with rate limit#2079
Conversation
WalkthroughThis PR introduces a new Prometheus alert remediation action that automatically deletes the pod associated with a triggered alert. The action includes optional per-alert-label rate limiting to prevent excessive deletions, along with validation and documentation. ChangesNew delete_alert_pod action for Prometheus alerts
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
✅ Docker image ready for
Use this tag to pull the image for testing. 📋 Copy commandsgcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:4845f72
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/robusta-runner:4845f72 me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:4845f72
docker push me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:4845f72Patch Helm values in one line: helm upgrade --install robusta robusta/robusta \
--reuse-values \
--set runner.image=me-west1-docker.pkg.dev/robusta-development/development/robusta-runner-dev:4845f72 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@playbooks/robusta_playbooks/pod_actions.py`:
- Around line 47-53: Add a strict positive check for params.rate_limit in the
existing validation block: if params.rate_limit is not None, first verify
params.rate_limit > 0 and if not raise
ActionException(ErrorCodes.ILLEGAL_ACTION_PARAMS, "rate_limit must be a positive
integer greater than 0"); then continue to validate that params.rate_limit_field
is present as currently implemented (refer to params.rate_limit,
params.rate_limit_field, ActionException and ErrorCodes in the pod_actions.py
block).
- Around line 55-59: The current delete_alert_pod flow logs a missing rate-limit
label but continues to delete; change it to “fail closed”: inside the
delete_alert_pod function, when evaluating params.rate_limit (or equivalent
config) and field_value is None (the branch where you currently log the missing
label), stop the deletion by returning early or raising an exception instead of
proceeding; update the log to error-level and reference params.rate_limit_field
in the message so callers see which label is missing. Ensure this logic lives in
the same block that checks field_value and use the existing params and
field_value symbols to locate and modify the behavior.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b3cfbe74-96ae-41c9-8c1e-0a920c13cef7
📒 Files selected for processing (2)
docs/playbook-reference/actions/remediation.rstplaybooks/robusta_playbooks/pod_actions.py
No description provided.