Bug 1330323

Summary: oc process does not emit a non-zero exit code on invalid values
Product: OKD Reporter: Chris Ryan <cryan>
Component: ocAssignee: Steve Kuznetsov <skuznets>
Status: CLOSED CURRENTRELEASE QA Contact: Wei Sun <wsun>
Severity: low Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, mmccomas
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:17 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:

Description Chris Ryan 2016-04-25 21:47:11 UTC
Description of problem:
oc process does not emit a non-zero exit code when the template contains an invalid label value

Version-Release number of selected component (if applicable):
oc v1.1.6
kubernetes v1.2.0-36-g4a3f9c5


How reproducible:
Always 

Steps to Reproduce:
1. Download https://raw.githubusercontent.com/openshift-qe/v3-    testfiles/master/build/ruby22rhel7-template-sti.json

2. Modify the very last 'labels' line (line 479) with an invalid value, like: 
 "label!!": "value1"
3. run oc process on that file: 
oc process -f ruby22rhel7-template-sti.json
      error processing the template "ruby-helloworld-sample": Template "ruby-helloworld-sample" is invalid: labels: Invalid value: "label!!": 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"
      {
          "kind": "List",
          "apiVersion": "v1",
          "metadata": {},
          "items": null
      }
      
      
      [21:42:50] INFO> Exit Status: 0
4. Check the exit status:
echo $?


Actual results:
The command returns a zero exit code, even after failure

Expected results:
A non-zero exit code

Additional info:

Comment 1 Ben Parees 2016-04-26 16:51:01 UTC
pretty sure Steve is already fixing this here:
https://github.com/openshift/origin/pull/8049

Comment 2 Steve Kuznetsov 2016-10-06 12:24:44 UTC
Tested today on master, seems to work as desired:

$ oc version
oc v1.4.0-alpha.0+33f3e8f
kubernetes v1.4.0+776c994
features: Basic-Auth

Server https://10.13.137.202:8443
openshift v1.4.0-alpha.0
kubernetes v1.4.0-beta.3+d19513f

$ wget https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/build/ruby22rhel7-template-sti.json
$ vim ruby22rhel7-template-sti.json
# add "label!!": "value1" to the last JSON stanza as described above

$ oc process -f ruby22rhel7-template-sti.json 
error: error processing the template "ruby-helloworld-sample": Template "ruby-helloworld-sample" is invalid: labels: Invalid value: "label!!": 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')

$ echo $?
1

Comment 3 Chris Ryan 2016-10-06 18:55:24 UTC
Verified with:

$ oc version
oc v1.3.0
kubernetes v1.3.0+52492b4


oc v1.4.0-alpha.0+43d24b2
kubernetes v1.4.0+776c994

$ oc process -f ruby22rhel7-template-sti.json
error: error processing the template "ruby-helloworld-sample": Template "ruby-helloworld-sample" is invalid: labels: Invalid value: "label!!!": 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')

$ echo $?
1