Bug 1517700 - It will delete all the RCs in the project when deleting non-existing dc with name started or ended with special chars
Summary: It will delete all the RCs in the project when deleting non-existing dc with ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: openshift-controller-manager
Version: 3.7.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: 3.7.z
Assignee: Tomáš Nožička
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-27 09:21 UTC by Meng Bo
Modified: 2018-04-05 09:32 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2018-04-05 09:32:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0636 0 None None None 2018-04-05 09:32:45 UTC

Description Meng Bo 2017-11-27 09:21:33 UTC
Description of problem:
When trying to delete the non-existing dc with name started or ended with special chars, like _, -, *, =. It will report success and all the RCs in the project are deleted.

Version-Release number of selected component (if applicable):
v3.7.9

How reproducible:
always

Steps to Reproduce:
1. Try to delete dc with name started or ended with special chars
[user1@ose-master ~]$ oc get rc 
NAME      DESIRED   CURRENT   READY     AGE
test-rc   2         2         0         2s
[user1@ose-master ~]$ oc get dc
No resources found.
[user1@ose-master ~]$ oc delete dc _aaaa                         # non-existing dc with name started or ended with special chars
deploymentconfig "_aaaa" deleted
[user1@ose-master ~]$ oc get rc
No resources found.

2.
3.

Actual results:
[user1@ose-master ~]$ oc delete dc _aaaa --loglevel=6
....
I1127 16:03:32.645365    6594 round_trippers.go:405] PATCH https://ose-master.bmeng.local:8443/apis/apps.openshift.io/v1/namespaces/bmengp1/deploymentconfigs/_aaaa 404 Not Found in 8 milliseconds
I1127 16:03:32.647934    6594 round_trippers.go:405] GET https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers 200 OK in 2 milliseconds
I1127 16:03:32.649474    6594 round_trippers.go:405] GET https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers/test-rc 200 OK in 1 milliseconds
I1127 16:03:32.650558    6594 round_trippers.go:405] GET https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers 200 OK in 0 milliseconds
I1127 16:03:32.651675    6594 round_trippers.go:405] GET https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers/test-rc 200 OK in 0 milliseconds
I1127 16:03:32.661839    6594 round_trippers.go:405] PUT https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers/test-rc 200 OK in 7 milliseconds
I1127 16:03:32.671572    6594 round_trippers.go:405] GET https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers/test-rc 200 OK in 9 milliseconds
I1127 16:03:32.673784    6594 round_trippers.go:405] GET https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers?fieldSelector=metadata.name%3Dtest-rc&resourceVersion=285985&watch=true 200 OK in 1 milliseconds
I1127 16:03:32.929943    6594 round_trippers.go:405] DELETE https://ose-master.bmeng.local:8443/api/v1/namespaces/bmengp1/replicationcontrollers/test-rc 200 OK in 146 milliseconds
....
deploymentconfig "_aaaa" deleted


Expected results:


Additional info:

Comment 1 Tomáš Nožička 2017-11-27 19:34:28 UTC
I could reproduce it and traced it down to:

 1. cli doesn't validate the name (even upstream I think)
 2. apimachinery bug that ignores the error and returns selector matching all

Comment 2 Tomáš Nožička 2017-11-29 14:39:57 UTC
https://github.com/openshift/origin/pull/17492

Comment 3 Tomáš Nožička 2018-01-02 09:17:16 UTC
backport for ose 3.7 - https://github.com/openshift/ose/pull/979

Comment 4 ge liu 2018-01-31 05:37:11 UTC
Verified on ocp 3.7,

openshift v3.7.27
kubernetes v1.7.6+a08f5eeb62
etcd 3.2.8

# oc delete dc _aaaa 
Error from server (BadRequest): unable to parse requirement: invalid label value: "_aaaa": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
[root@ip-172-18-1-126 ~]# oc get rc
NAME                   DESIRED   CURRENT   READY     AGE
deployment-example-1   1         1         1         2m

# oc delete dc deployment-example _aaaa 
deploymentconfig "deployment-example" deleted
Error from server (BadRequest): unable to parse requirement: invalid label value: "_aaaa": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
# oc get dc
ocNo resources found.
# oc get rc
No resources found.

Comment 8 errata-xmlrpc 2018-04-05 09:32:08 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-2018:0636


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