Bug 1804049 - Alertmanager: Prevent duplicate/same router label keys on Receiver forms
Summary: Alertmanager: Prevent duplicate/same router label keys on Receiver forms
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.5.0
Assignee: David Taylor
QA Contact: XiaochuanWang
URL:
Whiteboard:
Depends On:
Blocks: 1804777
TreeView+ depends on / blocked
 
Reported: 2020-02-18 05:46 UTC by XiaochuanWang
Modified: 2020-08-04 18:00 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: Admin -> Cluster Settings -> Global Configuration -> Alertmanager -> Create Receiver. You are able create two routing labels with the same name/key. Consequence: When 2 pairs of routing label have same key, it only shows latest one on list page. But if one of them use regular expression, detail page separate them as 2 pairs. If both of them are using/not using regular expression, the first one is replaced by second one. Fix: Added validation and prevent adding two routing labels with same name/key. Result: When one enters a routing label name which already exists they are presented with an error message "Routing Label names must be unique" and Save button is disabled until label name is changed.
Clone Of:
: 1804777 (view as bug list)
Environment:
Last Closed: 2020-08-04 18:00:50 UTC
Target Upstream Version:


Attachments (Terms of Use)
error trying to same yaml with multiple, same keys in single block (31.43 KB, image/png)
2020-02-18 19:24 UTC, David Taylor
no flags Details
ok to have same keys in different blocks (match & match_re) (15.98 KB, image/png)
2020-02-18 19:26 UTC, David Taylor
no flags Details


Links
System ID Priority Status Summary Last Updated
Github openshift console pull 4391 None closed Bug 1804049: Alertmanager - Prevent duplicate/same router label keys on Receiver forms 2020-06-23 08:33:23 UTC
Red Hat Product Errata RHBA-2020:2409 None None None 2020-08-04 18:00:53 UTC

Description XiaochuanWang 2020-02-18 05:46:47 UTC
Description of problem:
User create Alert receiver with multiple routing label.
When 2 pairs of routing label have same key, it only shows latest one on list page. But if one of them use regular expression, detail page separate them as 2 pairs. If both of them are using/not using regular expression, the first one is replaced by second one.

Version-Release number of selected component (if applicable):
4.4.0-0.nightly-2020-02-16-205302

How reproducible:
Always

Steps to Reproduce:
1. User create Alert receiver from alertmanager with multiple routing labels.
User have 2 pairs of routing labels with same key, both are using regular expression (or both are not). Check on list page and Edit form page.
2. User have 2 pairs of routing label with same key, one is using regular expression, the other doesn't. check list and detail page.
3. Create pairs of routing label with different label


Actual results:
1. Both list page and detail page only show the 2nd one, the 1st one is replaced.
2. List page only shows the regular expression pair. Detail page show both, but it reorders the regular expression pair as latest pair.
3. It only display as one pair of label, using comma to separate them.

Expected results:
1&2. Both list and detail page should be consistent. Either labels with same key should be replaced to the latest one no matter using regular expression or not. Or the one using regular expression and the other which not using it should be separated, list page should show as separated one as well.
3. Display for separated labels need to display as 2 individual label. 

Additional info:

Comment 1 David Taylor 2020-02-18 19:24:31 UTC
Created attachment 1663882 [details]
error trying to same yaml with multiple, same keys in single block

Comment 2 David Taylor 2020-02-18 19:26:18 UTC
Created attachment 1663883 [details]
ok to have same keys in different blocks (match & match_re)

Comment 3 David Taylor 2020-02-18 19:49:13 UTC
- Cannot have same keys in single block (see attachment 1663882 [details])
- When checking 'Regular Expression' checkbox, label key-values are saved to different block than non-regex labels (see attachment attachment 1663883 [details])

I see two issues:

a) In the case where one has saved Routing labels like: "severity: warning [ ]Regular Exp." and "severity: ^err$ [X]Regular Exp." (which is valid, but I'm not sure logical given Alertmanagers AND'ing of route labels), the list page should show both labels -this is a bug

b) Handling Same Keys - the code does reduce to unique keys per 'match' and 'match_re' yaml blocks.  I recommend adding a validation to the Route Label Editor which highlights duplicate route label keys per regex and non-regex label sets.  Not sure how logical/typical this usecase is though, would user enter 'severity: warning' and 'severity: error' labels thinking it was an OR situation (labels are AND'ed).  Currently, I believe 'severity: error' would only be saved.

Comment 4 David Taylor 2020-02-18 22:24:38 UTC
I have a fix for (a) list page showing same key for regex and non-regex routing labels.

irt. (b) Handling Same Keys - The instructions on the page say "Firing alerts with labels that match -->ALL<-- of these selectors...' so would a user logically create 'severity: warning' and 'severity: error' labels knowing an alert can never match these conditions?  If so, should be validate for this, or are we ok with just saving single 'severity: error' label.  I can look into validation, but it's complicated by the fact that the Route Label Editor is multi-rowed and we need to validate sets of labels (regex, non-regex).

Comment 5 David Taylor 2020-02-18 22:30:32 UTC
Similarly, a user can create "severity: warning [ ]Regular Exp."(non-regex) and "severity: ^info$ [X]Regular Exp." (regex w/ same key) which will be saved as separate routing labels, but logically the non-regex would need to/could be included in the regex label (due to ANDing). 

A simpler validation would be to just to make sure all routing labels are unique between non-regex(match) and regex (match_re) labels, even though technically you could have same keys in a regex and a non-regex label.  idk, it's complex :-)

Comment 6 XiaochuanWang 2020-02-19 01:53:13 UTC
Thanks David! Plz feel free to rephrase this bug since it includes different scenarios and complex logic.

Comment 7 David Taylor 2020-02-19 18:02:02 UTC
Hi, after review with team-monitoring the following doc:

https://docs.google.com/document/d/1teEFDKZvgVEmgGSs-ZIJwLZEy7pHy-c-tZdSVKgCJ9k/edit

We determined that the fix for this bug is to show an error message if user attempts to save form with duplicate/same router keys.  Since user will not be able to save same keys, there is no need to update the list view to handle duplicate/same keys keys.

Comment 10 XiaochuanWang 2020-03-06 09:51:37 UTC
This is fixed on 4.5.0-0.ci-2020-03-04-223611
Duplicated label key is not allowed to be saved.
Both by console forms and YAML

Comment 12 errata-xmlrpc 2020-08-04 18:00:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.5 image release advisory), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:2409


Note You need to log in before you can comment on or make changes to this bug.