Bug 1619869 - oc patch on custom resource returns error
Summary: oc patch on custom resource returns error
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Master
Version: 3.11.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 3.11.z
Assignee: Maciej Szulik
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-08-22 01:03 UTC by Justin Pierce
Modified: 2018-10-26 08:55 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-26 08:55:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
loglevel output of patch (13.52 KB, text/plain)
2018-08-22 01:12 UTC, Justin Pierce
no flags Details

Description Justin Pierce 2018-08-22 01:03:37 UTC
Description of problem:
Patching a custom resource as follows always returns an error:
$ oc patch  prometheusrule/prometheus-k8s-rules  -n openshift-monitoring --type=strategic -p '{"metadata": {"annotations": {"cr_patch": "yep"}}}'
Error from server (UnsupportedMediaType): the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json

Running an identical patch against a standard resource works:
oc patch node ip-172-31-79-85.us-east-2.compute.internal --type=strategic -p '{"metadata": {"annotations": {"cr_patch": "yep"}}}'
node "ip-172-31-79-85.us-east-2.compute.internal" patched


Version-Release number of selected component (if applicable):
v3.10, v3.11

How reproducible:
100%

Steps to Reproduce:
1. oc patch a custom resource definition instance
2.
3.

Actual results:
An error is reported when an attempt is made to patch a custom resource

Expected results:
All API resources should be patchable. 

Additional info:

Comment 1 Justin Pierce 2018-08-22 01:12:06 UTC
Created attachment 1477760 [details]
loglevel output of patch

Comment 2 Xingxing Xia 2018-08-22 01:58:06 UTC
From the error message, pls try 'json' or 'merge' patch.

Per https://trello.com/c/i86svfMn/973-5-control-plane-custom-resource-definitions#comment-59c130c000115a9d5feda5c6 , 'strategy' is not supported. It may be supported in future.

Comment 3 Justin Pierce 2018-08-22 12:43:55 UTC
If it cannot be supported in the short term, an error message indicating the unsupported nature of the default strategy would be helpful.

Comment 4 Beni Paskin-Cherniavsky 2018-10-23 07:37:50 UTC
Update: according to https://github.com/kubernetes/kubernetes/issues/58414, there is no plan to support strategic merge patch for CRD.
https://github.com/kubernetes/kubernetes/pull/53558 improved the error message.


Note You need to log in before you can comment on or make changes to this bug.