Bug 2064705

Summary: the alertmanagerconfig validation catches the wrong value for invalid field
Product: OpenShift Container Platform Reporter: Junqi Zhao <juzhao>
Component: MonitoringAssignee: Joao Marcal <jmarcal>
Status: CLOSED ERRATA QA Contact: Junqi Zhao <juzhao>
Severity: low Docs Contact:
Priority: medium    
Version: 4.11CC: amuller, anpicker, aos-bugs, spasquie, sthaha
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-10 10:54:28 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:
Embargoed:

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