Bug 1247676

Summary: When a required parameter from an application template is missing, we need to tell the user.
Product: OpenShift Container Platform Reporter: Grant Shipley <gshipley>
Component: BuildAssignee: Ben Parees <bparees>
Status: CLOSED CURRENTRELEASE QA Contact: Wenjing Zheng <wzheng>
Severity: low Docs Contact:
Priority: medium    
Version: 3.0.0CC: aos-bugs, bparees, dmcphers, jliggitt, jokerman, libra-bugs, libra-onpremise-devel, mmccomas, rcarvalh, xtian
Target Milestone: ---Keywords: UpcomingRelease
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-23 14:27:03 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 Grant Shipley 2015-07-28 15:17:59 UTC
Description of problem:
When a required parameter is missing for an application template is missing, we need to inform the user how to correct the issue. We also need to stop creating the services/routes/etc unless the entire application template can be created.  Doing it the way we do leaves the system/project in a broken state.

Version-Release number of selected component (if applicable):
3.0 GA

How reproducible:
Everytime

Steps to Reproduce:
1. oc new-project thisbreak
2. oc new-app --template=jws-tomcat8-basic-sti


Actual results:
services/jws-app
routes/jws-app-http-route
imagestreams/jws-app
Error: BuildConfig "jws-app" is invalid: parameters.source.git.uri: required value
deploymentconfigs/jws-app


Expected results:
if I configuration item is missing, the new-app transaction needs to be aborted and an error message such as:
Hey guy, you need to pass in a git uri parameter for this template to work.  Try this command instead:

 oc new-app --template=jws-tomcat8-basic-sti --param=GIT_URI=https://github.com/gshipley/tomcat-openshift3.git


Additional info:
we give the user the missing field, but leave it up to the developer to figure out the correct naming of the field and how to fix the issue.  We also leave the project in a horribly broken state in that some things were created and some were not.

Comment 2 Jordan Liggitt 2015-08-06 15:53:28 UTC
Template parameters now support an optional "required" attribute. Templates should be updated to set that

Comment 3 Jordan Liggitt 2015-08-06 15:54:34 UTC
The CLI should be updated to process errors from a "process template" step to tell the user which parameter had errors (the errors come back with "parameters[0]" which need to be correlated to the actual parameter name)

Comment 4 Ben Parees 2015-09-11 03:49:50 UTC
the error is a little better, it shows you the name of the parameter:

error: error processing template test/ruby-helloworld-sample: template "ruby-helloworld-sample" is invalid: parameters: invalid value '<*>(0xc20cd4dd80)parameters[4].value: required value, Details: parameter MYSQL_DATABASE is required and must be specified', Details: failure to generate parameter value

we might be able to clean that message up a little more.

we're never going to do the abort/rollback proposal, you can just run the template again and it will create the things that are missing.  we do not operate on a transactional model in v3.

Comment 5 Ben Parees 2015-09-12 04:21:24 UTC
better fix for the error message here:
https://github.com/openshift/origin/pull/4641

Comment 6 Wenjing Zheng 2015-09-15 10:09:03 UTC
If the template contains black value for required parameter, below error will appear when create with it with devenv-fedora-2340.
[wzheng@openshiftqe test]$ oc new-app sti2.json 
error: error processing template bug3/ruby-helloworld-sample: template "ruby-helloworld-sample" is invalid: parameters: invalid value '{Name:MYSQL_DATABASE DisplayName: Description:database name Value: Generate: From: Required:true}', Details: template.parameters[4]: parameter MYSQL_DATABASE is required and must be specified

But the original bug is about creating with invalid values which is not required parameter, like sourceURi, for if creating with blank sourceURi, the error still is not that clear like: Error: BuildConfig "jws-app" is invalid: parameters.source.git.uri: required value; can this be changed to more readable?

Comment 7 Michal Fojtik 2015-09-17 12:52:37 UTC
Ben, Wenjing so this is really about improving the error reporting from create operation where when it fails, we should give users more clean message about why it failed?

The 'parameters.source.git.uri' is not a template parameter, it is BuildConfig field. So the error you seen is a validation error coming from the REST call.

Comment 8 Ben Parees 2015-09-17 14:27:27 UTC
michal: yes that's correct.  i cleaned up the template part, but the create side logic will be harder to change.

Comment 9 Rodolfo Carvalho 2015-09-29 10:18:24 UTC
I'm trying to find out if there's anything left to be fixed here.

The introduction of the "required" flag in template parameters solved the original issue:

$ oc new-app --file=https://raw.githubusercontent.com/jboss-openshift/application-templates/master/webserver/jws-tomcat8-basic-s2i.json --param SOURCE_REPOSITORY_URL=""
error: error processing template demo/jws-tomcat8-basic-s2i: template "jws-tomcat8-basic-s2i" is invalid: parameters: invalid value '{Name:SOURCE_REPOSITORY_URL DisplayName: Description:Git source URI for applic
ation Value: Generate: From: Required:true}', Details: template.parameters[2]: parameter SOURCE_REPOSITORY_URL is required and must be specified



Now, if a template is not using a required template parameter to fill in the value of sourceURI, the current error message reads:

$ oc new-app --file=t.json
services/jws-app
routes/jws-app
imagestreams/jws-app
Error: BuildConfig "jws-app" is invalid: spec.source.git.uri: required value
deploymentconfigs/jws-app


That's the standard validation error message returned from the REST API.

Do we want to change that or anything else in the scope of this BZ?

Comment 10 Ben Parees 2015-09-29 12:29:11 UTC
Sounds like no, QE are you happy with the new message:
Error: BuildConfig "jws-app" is invalid: spec.source.git.uri: required value
deploymentconfigs/jws-app

?

Comment 11 Wenjing Zheng 2015-09-30 05:47:42 UTC
OK then, I will verify this bug now.

Comment 12 Brenton Leanhardt 2015-11-23 14:27:03 UTC
This fix is available in OpenShift Enterprise 3.1.