Skip to content

CNV-80608: management: add delete alert rule API#942

Open
sradco wants to merge 1 commit into
openshift:main-alerts-management-apifrom
sradco:alert-mgmt-restructured-03-delete-rule
Open

CNV-80608: management: add delete alert rule API#942
sradco wants to merge 1 commit into
openshift:main-alerts-management-apifrom
sradco:alert-mgmt-restructured-03-delete-rule

Conversation

@sradco
Copy link
Copy Markdown

@sradco sradco commented May 14, 2026

Add DELETE /api/v1/alerting/rules endpoint
for bulk deletion of user-defined alert
rules with full test coverage.

Also removes .github/workflows/unit-tests.yaml
as the OpenShift org runs all tests via Prow.

Signed-off-by: Shirly Radco sradco@redhat.com
Signed-off-by: João Vilaça jvilaca@redhat.com
Signed-off-by: Aviv Litman alitman@redhat.com
Co-authored-by: AI Assistant noreply@cursor.com

Add DELETE /api/v1/alerting/rules endpoint
for bulk deletion of user-defined alert
rules with full test coverage.

Signed-off-by: Shirly Radco <sradco@redhat.com>
Signed-off-by: João Vilaça <jvilaca@redhat.com>
Signed-off-by: Aviv Litman <alitman@redhat.com>
Co-authored-by: AI Assistant <noreply@cursor.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 14, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 14, 2026

@sradco: This pull request references CNV-80608 which is a valid jira issue.

Details

In response to this:

Add DELETE /api/v1/alerting/rules endpoint
for bulk deletion of user-defined alert
rules with full test coverage.

Also removes .github/workflows/unit-tests.yaml
as the OpenShift org runs all tests via Prow.

Signed-off-by: Shirly Radco sradco@redhat.com
Signed-off-by: João Vilaça jvilaca@redhat.com
Signed-off-by: Aviv Litman alitman@redhat.com
Co-authored-by: AI Assistant noreply@cursor.com

Made with Cursor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sradco
Once this PR has been reviewed and has the lgtm label, please assign kyoto for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 14, 2026

@sradco: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@sradco
Copy link
Copy Markdown
Author

sradco commented May 18, 2026

Hi @jgbernalp , @jan--f , @simonpasquier, I would appreciate your review of this PR

Comment thread api/openapi.yaml
type: object
required:
- id
- status_code
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This casing seems inconsistent, should we stick with camelCase?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yes I agree to change to statusCode

Comment thread api/openapi.yaml
properties:
ruleIds:
type: array
minItems: 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we set a max here?, it seems a large number of ids would execute sequential calls to the k8s api.

Comment thread api/openapi.yaml
Comment on lines +187 to +192
ruleIds:
type: array
minItems: 1
items:
type: string
description: List of stable alert rule IDs to delete.
Copy link
Copy Markdown

@avlitman avlitman May 19, 2026

Choose a reason for hiding this comment

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

maybe we can add maxItems

Suggested change
ruleIds:
type: array
minItems: 1
items:
type: string
description: List of stable alert rule IDs to delete.
ruleIds:
type: array
minItems: 1
maxItems: 100
items:
type: string
description: List of stable alert rule IDs to delete (at most 100 per request).

if yes we will need to update user_defined_alert_rule_bulk_delete.go accordingly

"github.com/openshift/monitoring-plugin/pkg/managementlabels"
)

func (c *client) DeleteUserDefinedAlertRuleById(ctx context.Context, alertRuleId string) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems this function is also deleting platform managed rules, is the name correct or the logic needs adjustment?

Comment on lines +112 to +114
} else if len(newRules) != len(group.Rules) {
updated = true
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this needed, it seems the filterRulesById changes the updated value already. Can we simplify this logic to make it more readable?

results := make([]DeleteAlertRuleResult, 0, len(payload.RuleIds))

for _, rawId := range payload.RuleIds {
id, err := parseParam(rawId, "ruleId")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC, this is parsed from a JSON input. why do we need to decode the rawId?

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants