Bug 1784725

Summary: Console should do special character check when create routing labels
Product: OpenShift Container Platform Reporter: shahan <hasha>
Component: Management ConsoleAssignee: David Taylor <dtaylor>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.3.0CC: aos-bugs, dtaylor, jokerman, yanpzhan
Target Milestone: ---   
Target Release: 4.4.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Create an Alertmanager Receiver, enter "#@$#$%" into a routing label key. Consequence: The receiver will be created, but get an AlertmanagerFailedReload Alert: "Reloading Alertmanager's configuration has failed for openshift-monitoring/alertmanager-main-x." Fix: Added form field validation to Create Receiver form. Result: Now when entering "#@$#$%" into a routing label key there is an field error message: "Invalid name". There is also an info in tooltip: "Label name must not begin with a digit and contain only alphanumeric characters or '_'.". Once cannot save the form until "#@$#$%" is removed from the routing label key/name.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-04 11:20:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description shahan 2019-12-18 07:48:41 UTC
Description of problem:
 Console should do special character check when create routing labels
Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. goto monitoring/alertmanagerconfig/receivers/~new page to create new receiver
2. input the required key and Routing Labels's name with special character, like .*% etc.
3. Then create

Actual results:
token=`oc -n openshift-monitoring sa get-token prometheus-k8s`
 oc -n openshift-monitoring exec -c prometheus prometheus-k8s-1  -- curl -k -H "Authorization: Bearer $token" 'https://prometheus-k8s.openshift-monitoring.svc:9091/api/v1/alerts' | jq
        "labels": {
          "alertname": "AlertmanagerFailedReload",
          "endpoint": "web",
          "instance": "",
          "job": "alertmanager-main",
          "namespace": "openshift-monitoring",
          "pod": "alertmanager-main-2",
          "service": "alertmanager-main",
          "severity": "warning"
        "annotations": {
          "message": "Reloading Alertmanager's configuration has failed for openshift-monitoring/alertmanager-main-2."
        "state": "firing",
        "activeAt": "2019-12-18T02:34:34.485794182Z",
        "value": "0e+00"

Logs from pod alertmanager-main-2:

level=info ts=2019-12-18T01:55:48.437Z caller=main.go:218 build_context="(go=go1.12.12, user=root@b6ceabe714d3, date=20191213-12:38:42)"
level=info ts=2019-12-18T01:55:48.465Z caller=cluster.go:623 component=cluster msg="Waiting for gossip to settle..." interval=2s
level=info ts=2019-12-18T01:55:48.507Z caller=coordinator.go:119 component=configuration msg="Loading configuration file" file=/etc/alertmanager/config/alertmanager.yaml
level=error ts=2019-12-18T01:55:48.507Z caller=coordinator.go:124 component=configuration msg="Loading configuration file failed" file=/etc/alertmanager/config/alertmanager.yaml err="invalid label name \"trtrt.*\""
Expected results:
Should have validation check like env setting:
 oc set env rc --all "^*^=test"
error: environment variable ^*^=test is invalid, a valid environment variable name must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name',  or 'MY_ENV.NAME',  or 'MyEnvName1', regex used for validation is '[-._a-zA-Z][-._a-zA-Z0-9]*')

Additional info:

Comment 2 Yanping Zhang 2020-02-13 06:53:56 UTC
Tested on ocp 4.4 env with payload 4.4.0-0.nightly-2020-02-12-191550. Create alertmanager receiver, set routing label key with: #@$#$%, there will be info: Invalid name, and there is info in tooltip: Label name must not begin with a digit and contain only alphanumeric characters or '_'.

The bug is fixed, so move it to Verified.

Comment 4 errata-xmlrpc 2020-05-04 11:20:24 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, and where to find the updated
files, follow the link below.

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