Bug 2100312

Summary: should use the same value for AlertRelabelConfig with oc explain
Product: OpenShift Container Platform Reporter: Junqi Zhao <juzhao>
Component: MonitoringAssignee: Jan Fajerski <jfajersk>
Status: CLOSED ERRATA QA Contact: Junqi Zhao <juzhao>
Severity: low Docs Contact: Brian Burt <bburt>
Priority: low    
Version: 4.11CC: anpicker, bburt, jfajersk, jmarcal
Target Milestone: ---   
Target Release: 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-17 19:50:29 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:
Bug Depends On:    
Bug Blocks: 2111345    

Description Junqi Zhao 2022-06-23 03:05:43 UTC
Description of problem:
tested https://issues.redhat.com/browse/MON-2091 with PR
launch 4.11.0-0.nightly-2022-06-22-190830,openshift/cluster-monitoring-operator#1676 aws

# oc create -f - << EOF
apiVersion: monitoring.openshift.io/v1alpha1
kind: AlertRelabelConfig
metadata:
  name: watchdog
  namespace: openshift-monitoring
spec:
  configs:
  - sourceLabels: [alertname, severity]
    regex: "Watchdog;none"
    targetLabel: severity
    replacement: critical
    action: replace
EOF
The AlertRelabelConfig "watchdog" is invalid: spec.configs[0].action: Unsupported value: "replace": supported values: "Replace", "Keep", "Drop", "HashMod", "LabelMap", "LabelDrop", "LabelKeep"

but from oc explian, replace is a valid value(other values are keep, drop, hashmod, labelmap, labeldrop, or labelkeep, which are lowercase), but the error reports supported values are capitalized: "Replace", "Keep", "Drop", "HashMod", "LabelMap", "LabelDrop", "LabelKeep".
I think we should use the same value for AlertRelabelConfig.

# oc explain AlertRelabelConfig.spec.configs.action
KIND:     AlertRelabelConfig
VERSION:  monitoring.openshift.io/v1alpha1

FIELD:    action <string>

DESCRIPTION:
     action to perform based on regex matching. Must be one of: replace, keep,
     drop, hashmod, labelmap, labeldrop, or labelkeep. Default is: 'replace'

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

How reproducible:
always

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 9 Junqi Zhao 2022-08-15 06:40:32 UTC
tested with 4.12.0-0.nightly-2022-08-12-053438, we still can not use lowercase action, but from the error logs, the supported values are the same with "oc explain AlertRelabelConfig.spec.configs.action", they are capitalized, is it expected? the tile for PR https://github.com/openshift/api/pull/1227 is wrong, it should be "exclude lowercase action in relabel_config validation", not include

# oc create -f - << EOF
apiVersion: monitoring.openshift.io/v1alpha1
kind: AlertRelabelConfig
metadata:
  name: watchdog
  namespace: openshift-monitoring
spec:
  configs:
  - sourceLabels: [alertname, severity]
    regex: "Watchdog;none"
    targetLabel: severity
    replacement: critical
    action: replace
EOF
The AlertRelabelConfig "watchdog" is invalid: spec.configs[0].action: Unsupported value: "replace": supported values: "Replace", "Keep", "Drop", "HashMod", "LabelMap", "LabelDrop", "LabelKeep"

# oc get crd alertrelabelconfigs.monitoring.openshift.io -oyaml 
...
                  properties:
                    action:
                      default: Replace
                      description: 'action to perform based on regex matching. Must
                        be one of: Replace, Keep, Drop, HashMod, LabelMap, LabelDrop,
                        or LabelKeep.  Default is: ''Replace'''
                      enum:
                      - Replace
                      - Keep
                      - Drop
                      - HashMod
                      - LabelMap
                      - LabelDrop
...

# oc explain AlertRelabelConfig.spec.configs.action
KIND:     AlertRelabelConfig
VERSION:  monitoring.openshift.io/v1alpha1

FIELD:    action <string>

DESCRIPTION:
     action to perform based on regex matching. Must be one of: Replace, Keep,
     Drop, HashMod, LabelMap, LabelDrop, or LabelKeep. Default is: 'Replace'

Comment 10 Jan Fajerski 2022-08-15 06:53:02 UTC
Yes that is expected, please see Joel review: https://github.com/openshift/api/pull/1227#discussion_r929888681

I'll change the PR title accordingly, good catch!

Comment 11 Junqi Zhao 2022-08-15 07:39:17 UTC
based on Comment 9 and Comment 10, set it to verified

Comment 14 errata-xmlrpc 2023-01-17 19:50:29 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 (Moderate: OpenShift Container Platform 4.12.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:7399