Bug 1827648

Summary: monitoring-rules-edit role can't edit PrometheusRules resources
Product: OpenShift Container Platform Reporter: Simon Pasquier <spasquie>
Component: MonitoringAssignee: Simon Pasquier <spasquie>
Status: CLOSED ERRATA QA Contact: Junqi Zhao <juzhao>
Severity: low Docs Contact:
Priority: low    
Version: 4.5CC: alegrand, anpicker, erooth, kakkoyun, lcosic, mloibl, pkrupa, surbania
Target Milestone: ---   
Target Release: 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-13 17:31:25 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 Simon Pasquier 2020-04-24 12:41:28 UTC
Description of problem:
A user with the monitoring-rules-edit role should be able to edit PrometheusRules resources.

Version-Release number of selected component (if applicable):
4.5 nightly

How reproducible:
Always

Steps to Reproduce:
1. Create a user and bind this user to the monitoring-rules-edit role for the openshift-monitoring namesapce.
oc adm policy add-role-to-user -n openshift-monitoring monitoring-rules-edit simon
2. Login as the new user.
3. Create a PrometheusRules resource in the openshift-monitoring namespace.
cat <<EOF | oc apply -f -
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: test
  namespace: openshift-monitoring
spec:
  groups:
  - name: test
    rules:
    - expr: 1
      record: test
EOF
3. Run "oc -n openshift-monitoring edit prometheusrules test" and edit the "expr" field (changing it to 0 for instance).

Actual results:
error: prometheusrules.monitoring.coreos.com "test" could not be patched: prometheusrules.monitoring.coreos.com "test" is forbidden: User "simon" cannot patch resource "prometheusrules" in A
PI group "monitoring.coreos.com" in the namespace "openshift-monitoring"
You can run `oc replace -f /tmp/oc-edit-e95x8.yaml` to try this update again.

Expected results:
No error.

Additional info:

Comment 3 Junqi Zhao 2020-04-28 03:15:14 UTC
Tested with 4.5.0-0.nightly-2020-04-27-192810, monitoring-rules-edit and monitoring-edit can update resources 
$ oc -n test edit prometheusrule/watchdog.rules
prometheusrule.monitoring.coreos.com/watchdog.rules edited

$ oc -n test edit ServiceMonitor new-servicemonitor
servicemonitor.monitoring.coreos.com/new-servicemonitor edited

$ oc -n test edit PodMonitor new-podmonitor
podmonitor.monitoring.coreos.com/new-podmonitor edited

Comment 4 errata-xmlrpc 2020-07-13 17:31:25 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.

https://access.redhat.com/errata/RHBA-2020:2409