Bug 1257800 - Error information indicating wrong name and value in command 'oc label', 'oc env' are duplicated
Error information indicating wrong name and value in command 'oc label', 'oc ...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
3.x
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Juan Vallejo
Yan Du
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-28 02:11 EDT by yapei
Modified: 2016-12-09 16:52 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-12-09 16:52:05 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description yapei 2015-08-28 02:11:28 EDT
Description of problem:
Duplicate error message for invalid parameter values in "oc label" and 'oc env'

Version-Release number of selected component (if applicable):
oc v1.0.4-510-g1be468d
kubernetes v1.1.0-alpha.0-1605-g44c91b1

How reproducible:
Always

Steps to Reproduce:
1. Create a new project
2. Create rc and pod resources using tempaltes
oc process -f /data/src/github.com/openshift/origin/examples/sample-app/application-template-stibuild.json | oc create -f - 
3. Add environment variable to replicationcontrollers
oc env rc/database-1 123$##%$#%=self -n yapei-test2 
4.Add labels for a pod
[fedora@ip-10-147-39-115 ~]$ oc label pod/database-1-wwts3 qwer1345%$$#=self -n yapei-test2
5. Update label for a pod
$ oc label pod/database-1-wwts3 deployment=qyuertr124%$###$% -n yapei-test2 --config=openshift.local.config/master/admin.kubeconfig



Actual results:
 
result for step3:
error: ReplicationController "database-1" is invalid: [spec.template.spec.containers[0].env[6].name: invalid value '1230#%0%', Details: must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName", spec.template.spec.containers[0].env[6].name: invalid value '1230#%0%', Details: must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName"]

result for step4:
The Pod "database-1-wwts3" is invalid.

* metadata.labels: invalid value 'qwer1345%732#', Details: must be a qualified name (at most 63 characters, matching regex ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]), with an optional DNS subdomain prefix (at most 253 characters, matching regex [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*) and slash (/): e.g. "MyName" or "example.com/MyName"
* metadata.labels: invalid value 'qwer1345%732#', Details: must be a qualified name (at most 63 characters, matching regex ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]), with an optional DNS subdomain prefix (at most 253 characters, matching regex [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*) and slash (/): e.g. "MyName" or "example.com/MyName"

result for step5:
error: invalid label spec: deployment=qyuertr124%!$(MISSING)%!(NOVERB)
see 'oc label -h' for help.

Expected results:
result for step3:
Error information should be displayed only once

result for step4:
Error information should be displayed only once

result for step5:
Should promote error information about invalid value "qyuertr124%$###$%"and give suggestion about what value is valid, just as the web console does [a valid label value is an alphanumberic(a-z,and 0-9)string,with a maximum length of 63 characters with the '-'character allowed anywhere except for the first and last character]

Additional info:
Comment 1 Juan Vallejo 2016-08-09 10:41:34 EDT
Hm, I cannot seem to replicate steps 3 and 5

oc version:
oc v1.3.0-alpha.0+8e93729-dirty
kubernetes v1.3.0+507d3a7
features: Basic-Auth

$ oc env rc/database-1 123$##%$#%=self

there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'oc get resource/<resource_name>' instead of 'oc get resource resource/<resource_name>'


$ oc label po/database-1-fn0r7 deployment=@#$^^

error: invalid label value: "deployment=@#": must match the regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? (e.g. 'MyValue' or 'my_value' or '12345')
See 'oc label -h' for help and examples.


Note:
Adding a label with an invalid key (step 4) does give me the same error multiple times, I will look into that.
Comment 2 Juan Vallejo 2016-08-09 18:14:27 EDT
Related PR: https://github.com/openshift/origin/pull/10317
Comment 3 yapei 2016-08-23 22:30:24 EDT
Invalid Env Name for 'oc set env'
# oc set env rc/database-1 test-abc=1234

error: ReplicationController "database-1" is invalid: [spec.template.spec.containers[0].env[5].name: Invalid value: "test-abc": must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName", spec.template.spec.containers[0].env[5].name: Invalid value: "test-abc": must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g. "my_name" or "MyName"]

Invalid Label Name for 'oc label'
# oc label pod/database-1-rxol6 qwer1345@-abc=self -n yapei-bug
The Pod "database-1-rxol6" is invalid.
metadata.labels: Invalid value: "qwer1345@-abc": name part must match the regex ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9] (e.g. 'MyName' or 'my.name' or '123-abc')

Invalid Label Value for 'oc label'
# oc label pod/database-1-rxol6 self=qwer1345@-abc -n yapei-bug
error: invalid label value: "self=qwer1345@-abc": must match the regex (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? (e.g. 'MyValue' or 'my_value' or '12345')
See 'oc label -h' for help and examples.

For 'oc label' we got error message only once

However we still get duplicated error message for 'oc set env'(since 'oc env' is DEPRECATED:This command has been moved to "oc set env")
Comment 4 Juan Vallejo 2016-08-24 13:09:48 EDT
Thanks for catching this.
Related PR: https://github.com/openshift/origin/pull/10613
Comment 5 Xingxing Xia 2016-08-30 01:33:51 EDT
Fixed in:
openshift v1.3.0-alpha.3+d8c9694
kubernetes v1.3.0+507d3a7
etcd 2.3.0+git

[xxia@ip-172-18-13-122 ~]$ oc env rc/database-1 123$##%$#%=self
error: environment variables must be of the form key=value and can only contain letters, numbers, and underscores
[xxia@ip-172-18-13-122 ~]$ oc label pod/database-1-5gohf qwer1345%$$#=self
The Pod "database-1-5gohf" is invalid.
metadata.labels: Invalid value: "qwer1345%3880#": name part must match the regex ([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9] (e.g. 'MyName' or 'my.name' or '123-abc')

Now error message is not duplicated

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