Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: notification rules with the same name #23925

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

alespour
Copy link
Contributor

Description

API allows to create notification rules with the same name. This PR assumes that notification rules should have unique names and current behavior is a bug.

The fix includes changes in pkger. With the attached template, the diff output of influx apply --host http://localhost:8086 -f issue23781.yaml is correct when re-demploy is attempted (this is tested in cmd/influxd/launcher/pkger_test.go):

NOTIFICATION ENDPOINTS    +add | -remove | unchanged
+-----+--------------------------------------+------------------+------------------+
| +/- |            METADATA NAME             |        ID        |  RESOURCE NAME   |
+-----+--------------------------------------+------------------+------------------+
| -   | http-none-auth-notification-endpoint | 0a4c67f718fb6000 | no auth endpoint |
+-----+--------------------------------------+------------------+------------------+
| +   | http-none-auth-notification-endpoint | 0a4c67f718fb6000 | no auth endpoint |
+-----+--------------------------------------+------------------+------------------+
|                                                   TOTAL       |        1         |
+-----+--------------------------------------+------------------+------------------+

NOTIFICATION RULES    +add | -remove | unchanged
+-----+---------------+------------------+---------------+-------------+-------+--------+------------------+------------------+---------------+
| +/- | METADATA NAME |        ID        | RESOURCE NAME | DESCRIPTION | EVERY | OFFSET |  ENDPOINT NAME   |   ENDPOINT ID    | ENDPOINT TYPE |
+-----+---------------+------------------+---------------+-------------+-------+--------+------------------+------------------+---------------+
| -   | rule-uuid     | 0a4c68d0a79ac000 | rule_0        | desc_0      | 10m0s | 30s    | no auth endpoint | 0a4c67f718fb6000 | http          |
+-----+---------------+------------------+---------------+-------------+-------+--------+------------------+------------------+---------------+
| +   | rule-uuid     | 0a4c68d0a79ac000 | rule_0        | desc_0      | 10m0s | 30s    | no auth endpoint | 0a4c67f718fb6000 | http          |
+-----+---------------+------------------+---------------+-------------+-------+--------+------------------+------------------+---------------+
|                                                                                                                 TOTAL       |       1       |
+-----+---------------+------------------+---------------+-------------+-------+--------+------------------+------------------+---------------+

issue23781.yaml

apiVersion: influxdata.com/v2alpha1
kind: NotificationEndpointHTTP
metadata:
  name:  http-none-auth-notification-endpoint # on export of resource created from this, will not be same name as this
spec:
  name: no auth endpoint
  type: none
  description: http none auth desc
  method: GET
  url:  https://www.example.com/endpoint/noneauth
  status: inactive
---
apiVersion: influxdata.com/v2alpha1
kind: NotificationRule
metadata:
  name:  rule-uuid
spec:
  name:  rule_0
  description: desc_0
  endpointName: http-none-auth-notification-endpoint
  every: 10m
  offset: 30s
  messageTemplate: "Notification Rule: ${ r._notification_rule_name } triggered by check: ${ r._check_name }: ${ r._message }"
  status: active
  statusRules:
    - currentLevel: WARN
    - currentLevel: CRIT
      previousLevel: OK
  tagRules:
    - key: k1
      value: v2
      operator: eQuAl
    - key: k1
      value: v1
      operator: eQuAl 

@alespour alespour marked this pull request as ready for review November 21, 2022 08:44
@alespour alespour requested a review from a team as a code owner November 21, 2022 08:44
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.

NotificationRules - able to create rules with same name
1 participant