Bug 2064705 - the alertmanagerconfig validation catches the wrong value for invalid field
Summary: the alertmanagerconfig validation catches the wrong value for invalid field
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Monitoring
Version: 4.11
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: ---
: 4.11.0
Assignee: Joao Marcal
QA Contact: Junqi Zhao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-03-16 11:48 UTC by Junqi Zhao
Modified: 2022-08-10 10:54 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-08-10 10:54:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift cluster-monitoring-operator pull 1648 0 None open Bug 2064705: [bot] Synchronize versions of the downstream components 2022-04-27 08:46:31 UTC
Github prometheus-operator prometheus-operator pull 4642 0 None Merged validation: Fix incorrect field in error response message for durations 2022-03-21 10:15:52 UTC
Red Hat Product Errata RHSA-2022:5069 0 None None None 2022-08-10 10:54:54 UTC

Description Junqi Zhao 2022-03-16 11:48:29 UTC
Description of problem:
Tested with PR
https://github.com/openshift/cluster-monitoring-operator/pull/1567
lauched cluster-bot cluster:
launch 4.11-ci,openshift/cluster-monitoring-operator#1567

set "repeatInterval: 12hours" in AlertmanagerConfig which value is wrong, it reported error "repeatInterval 5m does not match required regex: ^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$", but it is actually "repeatInterval: 12hours"

steps:
# oc new-project test;
# oc -n test create -f - << EOF
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  name: invalid-test-config
  labels:
    alertmanagerConfig: example
spec:
  route:
    groupBy: ['job']
    groupWait: 30s
    groupInterval: 5m
    repeatInterval: 12hours
    receiver: webhook
  receivers:
  - name: webhook
    webhookConfigs:
    - url: 'https://example.com'
      sendResolved: true
      httpConfig:
        followRedirects: true
  - name: wechat-example
    wechatConfigs:
    - apiURL: https://wechatserver:8080/
      corpID: wechat-corpid
      apiSecret:
        name: wechat-config
        key: apiSecret
EOF

The  "alertmanagerconfigs" is invalid: : repeatInterval 5m does not match required regex: ^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$

# oc explain AlertmanagerConfig.spec.route.repeatInterval
KIND:     AlertmanagerConfig
VERSION:  monitoring.coreos.com/v1alpha1

FIELD:    repeatInterval <string>

DESCRIPTION:
     How long to wait before repeating the last notification. Must match the
     regular
     expression`^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$`
     Example: "4h"



Version-Release number of selected component (if applicable):
tested with PR

How reproducible:
always

Steps to Reproduce:
1. see the description
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Simon Pasquier 2022-03-21 10:15:52 UTC
It will be fixed when upstream releases v0.56.0 (planned for 2022/4/20) and we bring it downstream.

Comment 4 Junqi Zhao 2022-04-28 10:54:37 UTC
tested with 4.11.0-0.nightly-2022-04-27-234931, followed the steps in Comment 0, error now is expected:
The  "alertmanagerconfigs" is invalid: : repeatInterval 12hours does not match required regex: ^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$

Comment 7 Simon Pasquier 2022-06-14 08:01:37 UTC
Downstream Prometheus operator is based on v0.57.0 which includes the fix.

Comment 9 Junqi Zhao 2022-06-14 12:47:07 UTC
tested with 4.11.0-0.nightly-2022-06-11-054027, followed the steps in Comment 0, it throws out error for the correct invalid filed value:

The  "alertmanagerconfigs" is invalid: : repeatInterval 12hours does not match required regex: ^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$

# oc -n openshift-monitoring logs -c prometheus-operator prometheus-operator-7bb758d69f-m2pxm
level=info ts=2022-06-14T03:27:18.303314722Z caller=main.go:220 msg="Starting Prometheus Operator" version="(version=0.57.0, branch=rhaos-4.11-rhel-8, revision=d7887f2)"

Comment 13 errata-xmlrpc 2022-08-10 10:54:28 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 (Important: OpenShift Container Platform 4.11.0 bug fix and security update), 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/RHSA-2022:5069


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