Bug 1776100

Summary: `oc edit clusterresourcequota` cannot work
Product: OpenShift Container Platform Reporter: Xingxing Xia <xxia>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: medium Docs Contact:
Priority: high    
Version: 4.3.0CC: aos-bugs, jokerman, mfojtik, wkulhane
Target Milestone: ---   
Target Release: 4.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 1776493 (view as bug list) Environment:
Last Closed: 2020-05-04 11:16: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:
Bug Depends On:    
Bug Blocks: 1776493, 1776495, 1776496    

Description Xingxing Xia 2019-11-25 07:03:23 UTC
Description of problem:
`oc edit clusterresourcequota` cannot work

Version-Release number of selected component (if applicable):
oc version -o yaml
clientVersion:
  buildDate: "2019-11-22T12:21:19Z"
  gitCommit: 9d412f42b3e753fd78eacd2ea7417a42fc02318d
  gitVersion: v4.3.0
...
openshiftVersion: 4.3.0-0.nightly-2019-11-24-183610
serverVersion:
  buildDate: "2019-11-22T14:41:49Z"
  gitVersion: v1.16.2
...

How reproducible:
Always

Steps to Reproduce:
1. cat > clusterresourcequota.yaml << EOF
kind: ClusterResourceQuota
apiVersion: quota.openshift.io/v1
metadata:
  name: loadbalancer-quota
spec:
  selector:
    annotations: null
    labels:
      matchExpressions:
      - key: managed.openshift.io/service-lb-quota-exempt-test
        operator: Exists
  quota:
    hard:
      services.loadbalancers: 8
EOF

oc create -f clusterresourcequota.yaml

2. oc edit clusterresourcequota loadbalancer-quota # add below annotation, then save
...
metadata:
  annotations:
    test: test1234
...

Actual results:
2. It fails with:
error: clusterresourcequotas.quota.openshift.io "loadbalancer-quota" could not be patched: the body of the request was in an unknown format - accepted media types inc
lude: application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml

Check more logs, found it uses below Content-Type:
oc edit --loglevel 7 clusterresourcequota loadbalancer-quota
...
PATCH https://...:6443/apis/quota.openshift.io/v1/clusterresourcequotas/loadbalancer-quota
Request Headers:
    Content-Type: application/strategic-merge-patch+json
...

Expected results:
2. Should succeed.

Comment 1 Maciej Szulik 2019-11-25 19:23:44 UTC
*** Bug 1772503 has been marked as a duplicate of this bug. ***

Comment 3 zhou ying 2019-11-27 07:24:46 UTC
Confirmed with latest oc version, the issue has fixed:

[root@dhcp-140-138 ~]# oc version -o yaml 
clientVersion:
  buildDate: "2019-11-26T18:34:34Z"
  compiler: gc
  gitCommit: fcec32910474e8f8160188b8b0e5ffb9ceec137e
  gitTreeState: clean
  gitVersion: v4.4.0
  goVersion: go1.12.12
  major: ""
  minor: ""
  platform: linux/amd64

[root@dhcp-140-138 ~]# oc edit clusterresourcequota loadbalancer-quota   # add below annotation, then save
...
metadata:
  annotations:
    test: test1234
...

clusterresourcequota.quota.openshift.io/loadbalancer-quota edited

Comment 5 errata-xmlrpc 2020-05-04 11:16: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, 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:0581