[api] when deploying environment, failed package validation error results in misleading exception
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Murano |
Fix Released
|
High
|
Steve McLellan |
Bug Description
When deploying an environment with a package that contained a wrongly named .png file for the logo which was actually a .jpeg file, the murano engine wrongly reports a NoClassFound exception.
In my case, I get the following output:
2014-05-09 15:52:13.360 14584 DEBUG muranoclient.
HTTP/1.1 200 OK
date: Fri, 09 May 2014 22:52:13 GMT
content-length: 427
content-type: application/json
{"packages": [{"class_
log_http_response /var/www/
2014-05-09 15:52:41.927 14584 DEBUG muranoclient.
2014-05-09 15:52:41.958 14584 DEBUG muranoclient.
HTTP/1.1 200 OK
date: Fri, 09 May 2014 22:52:41 GMT
content-length: 18427
content-type: application/
log_http_response /var/www/
2014-05-09 15:55:32.590 14584 ERROR muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
2014-05-09 15:55:32.590 14584 TRACE muranoapi.
The function where the exception is caught is defined in muranoapi/
def load_definition
try:
package = self.package_
return package.
except Exception, e:
raise exceptions.
Because the code is written to capture *any* exception, a misleading message is collected by the traceback above.
A closer look revels that the loading error occurs on the murano-api endpoint side, when the application package is being loaded. Specifically, the following function, for validating the logo file, results in an exception:
muranoapi/
def _load_logo(self, validate=False):
logo_file = self._logo or 'logo.png'
full_path = os.path.
if not os.path.
return
try:
if validate:
if imghdr.
with open(full_path) as stream:
except Exception as ex:
trace = sys.exc_info()[2]
raise e.PackageLoadError(
This is, in a way, 2 bugs:
(1) The error reporting is a bit misleading in that the murano-api endpoint should return a more meaningful error which is passed back up the chain on the engine side and
(2) The validation being done on the logo file here should also take place when the package is being imported to begin with.
Changed in murano: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
importance: | Medium → High |
milestone: | none → juno-1 |
Changed in murano: | |
assignee: | nobody → Steve McLellan (sjmc7) |
Changed in murano: | |
status: | Fix Committed → Fix Released |
Changed in murano: | |
milestone: | juno-1 → 2014.2 |
<tsufiev> the right solution is to validate package at the import stage /github. com/stackforge/ murano/ blob/master/ murano/ packages/ application_ package. py#L163
<ativelkov> It should be done, and, I think, it is done
<ativelkov> however if you import the package with manage.py, then no validation will be run
<sjmc7> i think we can fix this one
<sjmc7> at least validate the image
<ativelkov> So, what should be the correct fix for it?
<ruhe> ativelkov: i'm going to remove the import logic from manage.py soon
<ativelkov> It is validated, I believe\
<sjmc7> where we can, we should not allow invalid packages
<ativelkov> https:/
<ativelkov> This is the validation for PNG