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:
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
https://github.com/openshift/origin/pull/17492
backport for ose 3.7 - https://github.com/openshift/ose/pull/979
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.
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