Bug 1247676 - When a required parameter from an application template is missing, we need to tell the user.
When a required parameter from an application template is missing, we need to...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build (Show other bugs)
3.0.0
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Ben Parees
Wenjing Zheng
: UpcomingRelease
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-28 11:17 EDT by Grant Shipley
Modified: 2015-11-23 09:27 EST (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-11-23 09:27:03 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 Grant Shipley 2015-07-28 11:17:59 EDT
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 11:53:28 EDT
Template parameters now support an optional "required" attribute. Templates should be updated to set that
Comment 3 Jordan Liggitt 2015-08-06 11:54:34 EDT
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-10 23:49:50 EDT
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 00:21:24 EDT
better fix for the error message here:
https://github.com/openshift/origin/pull/4641
Comment 6 Wenjing Zheng 2015-09-15 06:09:03 EDT
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 08:52:37 EDT
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 10:27:27 EDT
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 06:18:24 EDT
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 08:29:11 EDT
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 01:47:42 EDT
OK then, I will verify this bug now.
Comment 12 Brenton Leanhardt 2015-11-23 09:27:03 EST
This fix is available in OpenShift Enterprise 3.1.

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