Details
-
Bug
-
Status: Done
-
Medium
-
Resolution: Fixed
-
None
-
FB-perconalab/pmm-server-fb:PR-1275-2267a7c
-
0
-
01 - Server Features, 02 - Server Features, 03 - Server Features, 04 - Server Features
-
Yes
-
Yes
-
Impediment
-
Server Features
Description
There is some inconsistency if the user tries to add a new Rule Template with the already present name (on the backend). On the UI this name is represented as a summary. If the user adds the same name, the notification says: Template with name "name_rule111" (not human-readable) not found.
Steps to reproduce:
Navigate to IA>>> Alert Rule Templates tab
Upload Alert Rule Template with e.g. name1 and save it
Click on Update and try to update the name of the template above, e.g. name1 >>>name111
Actual result:
Template with name "name_rule111" not found.
Expected result:
Update notification that the same rule exists but not shown name, e.g. Template not found.
Point out that the template name can not be edited or while adding the template that the name should be unique.
Suggested implementation (discussed on Slack)
- Use the object's unique identifier `name` for both Update and Delete operations
- Add the field `name` to UpdateRequest
Add the field `name` to DeleteRequest and remove yaml itself(this is already done)- Whenever performing an Update, the code should make sure that the `name` retrieved from the database matches the `name` in the YAML file.
How to test:
- Create user defined alert rule template with some name (e.g. A) and valid template.
- Try to update by using API v1/management/ia/Templates/Update, you need to pass same name in new field (A) - this should pass
- Try to change name inside yaml. So name != yaml.name - this should be error - Mismatch names.
Example request body:
{"name": "A","yaml":"---\r\ntemplates:\r\n - name: A\r\n version: 1\r\n summary: ANode high swap filling up\r\n expr: |-\r\n (1 - (node_memory_SwapFree_bytes \/ node_memory_SwapTotal_bytes))\r\n * 100\r\n > [[ .threshold ]]\r\n params:\r\n - name: threshold\r\n summary: A percentage from configured maximum\r\n unit: \"%\"\r\n type: float\r\n range: [0, 100]\r\n value: 80\r\n for: 5m\r\n severity: warning\r\n annotations:\r\n summary: Node swap is filling up ({{ $labels.node_name }})\r\n description: |-\r\n {{ $labels.node_name }} swap is filled up more than [[ .threshold ]]%.\r\n"}
Attachments
Issue Links
- is blocked by
-
PMM-7375 Inform users about the Template that they are editing and warn about limitations
-
- Done
-