Bug 2097716

Summary: settings under httpConfig is dropped with AlertmanagerConfig v1beta1
Product: OpenShift Container Platform Reporter: Junqi Zhao <juzhao>
Component: MonitoringAssignee: Simon Pasquier <spasquie>
Status: CLOSED ERRATA QA Contact: Junqi Zhao <juzhao>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.11CC: amuller, anpicker, hongyli
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-10 11:18:27 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-06-16 11:41:01 UTC
Description of problem:
tested https://issues.redhat.com/browse/MON-2567 with PR
launch 4.11.0-0.nightly-2022-06-15-161625,openshift/cluster-monitoring-operator#1682

create AlertmanagerConfig with v1beta1 version
# oc create -f - << EOF
apiVersion: monitoring.coreos.com/v1beta1
kind: AlertmanagerConfig
metadata:
  name: test-config
  labels:
    alertmanagerConfig: example
spec:
  route:
    groupBy: ['job']
    groupWait: 30s
    groupInterval: 5m
    repeatInterval: 12h
    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

checked the AlertmanagerConfig file, httpConfig is {}, followRedirects: true is dropped
# oc get AlertmanagerConfig test-config -oyaml
apiVersion: monitoring.coreos.com/v1beta1
kind: AlertmanagerConfig
metadata:
  creationTimestamp: "2022-06-16T11:23:20Z"
  generation: 1
  labels:
    alertmanagerConfig: example
  name: test-config
  namespace: default
  resourceVersion: "45914"
  uid: e9d3c61c-bd6e-4122-afd7-c51e9dcb7d8d
spec:
  receivers:
  - name: webhook
    webhookConfigs:
    - httpConfig: {}
      sendResolved: true
      url: https://example.com
  - name: wechat-example
    wechatConfigs:
    - apiSecret:
        key: apiSecret
        name: wechat-config
      apiURL: https://wechatserver:8080/
      corpID: wechat-corpid
  route:
    groupBy:
    - job
    groupInterval: 5m
    groupWait: 30s
    receiver: webhook
    repeatInterval: 12h

# oc explain AlertmanagerConfig.spec.receivers.webhookConfigs.httpConfig.followRedirects

KIND:     AlertmanagerConfig
VERSION:  monitoring.coreos.com/v1beta1

FIELD:    followRedirects <boolean>

DESCRIPTION:
     FollowRedirects specifies whether the client should follow HTTP 3xx
     redirects.


use the above AlertmanagerConfig sample with v1alpha1 version in 4.11.0-0.nightly-2022-06-15-161625 cluster, no such issue
# oc get AlertmanagerConfig test-config -oyaml
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata:
  creationTimestamp: "2022-06-16T11:23:41Z"
  generation: 1
  labels:
    alertmanagerConfig: example
  name: test-config
  namespace: default
  resourceVersion: "289618"
  uid: 9869fd51-023d-4390-b884-c20d24309458
spec:
  receivers:
  - name: webhook
    webhookConfigs:
    - httpConfig:
        followRedirects: true
      sendResolved: true
      url: https://example.com
  - name: wechat-example
    wechatConfigs:
    - apiSecret:
        key: apiSecret
        name: wechat-config
      apiURL: https://wechatserver:8080/
      corpID: wechat-corpid
  route:
    groupBy:
    - job
    groupInterval: 5m
    groupWait: 30s
    receiver: webhook
    repeatInterval: 12h

Version-Release number of selected component (if applicable):
tested https://issues.redhat.com/browse/MON-2567 with PR
Prometheus Operator version=0.57.0

How reproducible:
always

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

Actual results:
settings under httpConfig is dropped

Expected results:
should not drop

Additional info:

Comment 3 Junqi Zhao 2022-06-22 01:58:40 UTC
tested with 4.11.0-0.nightly-2022-06-21-151125, set more configurations under httpConfig, no lost data in the created AlertmanagerConfig
oc create -f - << EOF
apiVersion: monitoring.coreos.com/v1beta1
kind: AlertmanagerConfig
metadata:
  name: test-config
  namespace: default
  labels:
    alertmanagerConfig: example
spec:
  route:
    groupBy: ['job']
    groupWait: 30s
    groupInterval: 5m
    repeatInterval: 12h
    receiver: webhook
  receivers:
  - name: webhook
    webhookConfigs:
    - url: 'https://example.com'
      sendResolved: true
      httpConfig:
        followRedirects: true
        oauth2:
          clientId:
            secret:
              name: oauth2-credentials
              key: id
          clientSecret:
            name: oauth2-credentials
            key: secret
          tokenUrl: https://example.com/oauth2/token
          scopes:
          - scope3
          - scope4
          endpointParams:
            param3: value3
            param4: value4
  - name: wechat-example
    wechatConfigs:
    - apiURL: https://wechatserver:8080/
      corpID: wechat-corpid
      apiSecret:
        name: wechat-config
        key: apiSecret
EOF

# oc -n default get AlertmanagerConfig test-config -oyaml
apiVersion: monitoring.coreos.com/v1beta1
kind: AlertmanagerConfig
metadata:
  creationTimestamp: "2022-06-22T01:42:31Z"
  generation: 1
  labels:
    alertmanagerConfig: example
  name: test-config
  namespace: default
  resourceVersion: "75025"
  uid: 8abd3bec-e96a-4686-97c4-ef87340b514e
spec:
  receivers:
  - name: webhook
    webhookConfigs:
    - httpConfig:
        followRedirects: true
        oauth2:
          clientId:
            secret:
              key: id
              name: oauth2-credentials
          clientSecret:
            key: secret
            name: oauth2-credentials
          endpointParams:
            param3: value3
            param4: value4
          scopes:
          - scope3
          - scope4
          tokenUrl: https://example.com/oauth2/token
      sendResolved: true
      url: https://example.com
  - name: wechat-example
    wechatConfigs:
    - apiSecret:
        key: apiSecret
        name: wechat-config
      apiURL: https://wechatserver:8080/
      corpID: wechat-corpid
  route:
    groupBy:
    - job
    groupInterval: 5m
    groupWait: 30s
    receiver: webhook
    repeatInterval: 12h

Comment 6 errata-xmlrpc 2022-08-10 11:18:27 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