Skip to content

add delete_alert_pod action, with rate limit#2079

Merged
arikalon1 merged 2 commits into
masterfrom
delete-pod-rate-limit
May 14, 2026
Merged

add delete_alert_pod action, with rate limit#2079
arikalon1 merged 2 commits into
masterfrom
delete-pod-rate-limit

Conversation

@arikalon1
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Review Change Stack

Walkthrough

This 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.

Changes

New delete_alert_pod action for Prometheus alerts

Layer / File(s) Summary
Action parameters and implementation
playbooks/robusta_playbooks/pod_actions.py
Module imports expanded for logging, Optional, ActionParams, PrometheusKubernetesAlert, RateLimiter, and action. New DeleteAlertPodParams class stores optional rate_limit and rate_limit_field configuration. New delete_alert_pod action function retrieves the alert pod, validates parameters, enforces optional per-label rate limiting with error handling for misconfigured params, and deletes the pod or skips with logs when rate-limited.
Action documentation
docs/playbook-reference/actions/remediation.rst
Documentation directive added to register delete_alert_pod action with on_prometheus_alert trigger in the Remediation section.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • RoiGlinik
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether a description exists and relates to the changeset. Add a description explaining the purpose and functionality of the delete_alert_pod action and its rate limiting feature.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new delete_alert_pod action with rate limiting capability.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 delete-pod-rate-limit

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

Docker image ready for 4845f72 (built in 2m 8s)

⚠️ Warning: does not support ARM (ARM images are built on release only - not on every PR)

Use this tag to pull the image for testing.

📋 Copy commands

⚠️ Temporary images are deleted after 30 days. Copy to a permanent registry before using them:

gcloud 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:4845f72

Patch 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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b3531e and cb64d19.

📒 Files selected for processing (2)
  • docs/playbook-reference/actions/remediation.rst
  • playbooks/robusta_playbooks/pod_actions.py

Comment thread playbooks/robusta_playbooks/pod_actions.py
Comment thread playbooks/robusta_playbooks/pod_actions.py
@arikalon1 arikalon1 merged commit e071e11 into master May 14, 2026
7 checks passed
@arikalon1 arikalon1 deleted the delete-pod-rate-limit branch May 14, 2026 08:39
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.

2 participants