Bug 1257800

Summary: Error information indicating wrong name and value in command 'oc label', 'oc env' are duplicated
Product: OKD Reporter: Yadan Pei <yapei>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED CURRENTRELEASE QA Contact: Yan Du <yadu>
Severity: low Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, jvallejo, mmccomas, wmeng, xxia
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-09 21:52:05 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 Yadan Pei 2015-08-28 06:11:28 UTC
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 14:41:34 UTC
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 22:14:27 UTC
Related PR: https://github.com/openshift/origin/pull/10317

Comment 3 Yadan Pei 2016-08-24 02:30:24 UTC
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 17:09:48 UTC
Thanks for catching this.
Related PR: https://github.com/openshift/origin/pull/10613

Comment 5 Xingxing Xia 2016-08-30 05:33:51 UTC
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