Bug 1369679

Summary: Wrong prompt message when passing invalid env name to 'oc set env'
Product: OKD Reporter: Yadan Pei <yapei>
Component: ocAssignee: Juan Vallejo <jvallejo>
Status: CLOSED CURRENTRELEASE QA Contact: Xingxing Xia <xxia>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, ffranz, jvallejo, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-09 21:53:51 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 2016-08-24 06:46:59 UTC
Description of problem:
When invalid env name is carried in 'oc set env', oc gives incorrect message 

Version-Release number of selected component (if applicable):
oc v1.3.0-alpha.3+9b3ae69
kubernetes v1.3.0+507d3a7


How reproducible:
Always

Steps to Reproduce:
1.Create app resources
# oc process -f /data/src/github.com/openshift/origin/examples/sample-app/application-template-stibuild.json | oc create -f -
2.Add env for rc 'database-1' with correct env name
# oc set env rc/database-1 test=1234 -n yapei-bug
replicationcontroller "database-1" updated
3.Add another env for rc 'database-1' with invalid env name
# oc set env rc/database-1 test@-abc=1234 -n yapei-bug
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>'
4. oc set env rc/database-1 test-ttt=aaa1234
error: ReplicationController "database-1"  is invalid: [spec.template.spec.containers[0].env[6].name: Invalid  value: "test-ttt": 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: "test-ttt":  must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*): e.g.  "my_name" or "MyName"]
Duplicate error message is tracked in https://bugzilla.redhat.com/show_bug.cgi?id=1257800

Actual results:
3. Error message is not correct because I didn't specify a resource type as a separate argument:
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>'
4. Gives reasonable error message

Expected results:
3. Should give error message about invalid env name like step4

Additional info:

Comment 1 Juan Vallejo 2016-08-24 21:47:39 UTC
Related PR: https://github.com/openshift/origin/pull/10619

Comment 2 Fabiano Franz 2016-08-26 23:04:06 UTC
Fixed in https://github.com/openshift/origin/pull/10619

Comment 3 Xingxing Xia 2016-08-30 05:35:21 UTC
Fixed in:
openshift v1.3.0-alpha.3+d8c9694
kubernetes v1.3.0+507d3a7
etcd 2.3.0+git

$ oc set env rc/database-1 test-ttt=aaa1234
error: environment variables must be of the form key=value and can only contain letters, numbers, and underscores

Now prompt meaningful error message.