Bug 1409225 - cannot patch a value to empty string
Summary: cannot patch a value to empty string
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Node
Version: 3.3.1
Hardware: All
OS: All
unspecified
high
Target Milestone: ---
: ---
Assignee: Derek Carr
QA Contact: DeShuai Ma
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-30 12:58 UTC by raffaele spazzoli
Modified: 2017-01-05 03:03 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-04 17:58:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1267454 0 medium CLOSED It's better to show additional prompt when 'oc patch' non-existing fields of resource 2021-02-22 00:41:40 UTC

Internal Links: 1267454

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


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