Bug 1409225

Summary: cannot patch a value to empty string
Product: OpenShift Container Platform Reporter: raffaele spazzoli <rspazzol>
Component: NodeAssignee: Derek Carr <decarr>
Status: CLOSED NOTABUG QA Contact: DeShuai Ma <dma>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.3.1CC: aos-bugs, jokerman, mmccomas, xxia
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-04 17:58:00 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 raffaele spazzoli 2016-12-30 12:58:46 UTC
I'm trying to set the default project node selector to empty string as documented here:
https://blog.openshift.com/deploying-applications-to-specific-nodes/

This works if I use oc edit, but it doesn't work with oc patch.
the patch command execute successfully bit the object is left unchanged.

here is an example:
oc patch project glusterfs --patch '{ "metadata":{"annotation": { "openshift.io/node-selector": "" }}}'

Comment 1 Xingxing Xia 2017-01-03 11:05:10 UTC
(In reply to raffaele spazzoli from comment #0)
> here is an example:
> oc patch project glusterfs --patch '{ "metadata":{"annotation": {
> "openshift.io/node-selector": "" }}}'

Thanks for the report. Try plural "annotations", it works:

Before empty patch:
$ oc get namespace xxia-proj -o yaml | grep openshift.io/node-selector

openshift.io/node-selector: region=primary

Now empty patch:
$ oc patch namespace xxia-proj --patch '{ "metadata":{"annotations": {"openshift.io/node-selector": "" }}}' # Run via cluster-admin

After empty patch:
$ oc get namespace xxia-proj -o yaml | grep openshift.io/node-selector    openshift.io/node-selector: ""

Also, should use "oc patch namespace ... " instead of "oc patch project ...". The latter will show "metadata.annotations[openshift.io/node-selector] ... field is immutable, try updating the namespace" (As for this, see bug 1386401)

As for your report, see related bug 1267454

Comment 2 Derek Carr 2017-01-04 17:58:00 UTC
The command:

$ oc patch namespace xxia-proj --patch '{ "metadata":{"annotations": {"openshift.io/node-selector": "" }}}' # Run via cluster-admin

works as described.

Closing as not a bug.

Comment 3 Xingxing Xia 2017-01-05 03:03:20 UTC
(In reply to Derek Carr from comment #2)

> Closing as not a bug.

Right.
But IMO, at the beginning I didn't notice comment 0 uses singular "annotation" and just copied its command to reproduce, nearly thinking it as regression bug.

Singular "annotation" is kind of "non-existing field" said in bug 1267454, which causes UX problem and makes user confusion like the reporter of this bug.

Looking forward to the fix of bug 1267454