Create Cluster Template failing w/ mime error

Bug #1197479 reported by Matthew Farrellee
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sahara
Fix Released
Critical
Matthew Farrellee

Bug Description

Currently on master (58f3330d, pre 0.2) with savanna-dashboard (b77fea20) and RDO on EL6, the "Create" button of the "Create Cluster Template" form results in an error.

savanna-api reports -

(stack traces omitted)
ERROR savanna.utils.api [-] Request aborted with status code 400 and message 'Content type 'application/x-troff-man' isn't supported'

httpd's error_log reports -

(stack trace omitted)
RuntimeError: Unable to get Plugin, server returned code 500

Tags: 0.2
Revision history for this message
Matthew Farrellee (mattf) wrote :

Debugging reveals that api.py's Rest:route:decorator:handler is using 'resp_type' from the kwargs to guess the appropriate MIME type -

<Request 'http://localhost:8080/v1.0/7d250e3df0214d2b8bfe236e89f1b770/plugins/vanilla/1.1.2' [GET]>
kwargs = {'tenant_id': u'7d250e3df0214d2b8bfe236e89f1b770', 'version': u'1.1', 'resp_type': u'2', 'plugin_name': u'vanilla'}

The suffix_mime guess is thus for "res.2", which on my system is a legitimate type for application/x-troff-man -

$ rpm -qf /etc/mime.types
mailcap-2.1.31-2.el6.noarch
$ grep "1 2" /etc/mime.types
application/x-troff-man man 1 2 3 4 5 6 7 8

Changed in savanna:
assignee: nobody → Matthew Farrellee (farrellee)
Revision history for this message
Matthew Farrellee (mattf) wrote :

Sergey Lukjanov points out that the resp_type is getting set by the parsing later in the handler -

     f_rule = "/<tenant_id>" + rule
     self.add_url_rule(f_rule, endpoint, handler, **options)
-> ext_rule = f_rule + '.<resp_type>' <-
     self.add_url_rule(ext_rule, endpoint, handler, **options)

Revision history for this message
Matthew Farrellee (mattf) wrote :

The code traces back to,

commit 90115d2b197b778d6d85efd77db3a541b8fa8eac
Author: Sergey Lukjanov <email address hidden>
Date: Mon Feb 18 13:14:35 2013 +0400

    Initial implementation of REST API

No record was specifically found that explains the reason for the code.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to savanna (master)

Fix proposed to branch: master
Review: https://review.openstack.org/35523

Changed in savanna:
status: New → In Progress
Changed in savanna:
importance: Undecided → Critical
milestone: none → 0.2a1
tags: added: 0.2
Revision history for this message
Dmitry Mescheryakov (dmitrymex) wrote :

I think we can make client can ask for a specific Content-Type in response using 'Accept' header:
http://tools.ietf.org/html/rfc2616#section-14.1

Using URL suffixes like '.xml' and '.json' seems to dangerous because we also place variables at the end of URL. E.g.: /plugins/<plugin-name> or /node-group-templates/<template-id>

Revision history for this message
Sergey Lukjanov (slukjanov) wrote :

Dmitry, sure, we should check it and take a look on the common OpenStack approach.

P.S. currently Savanna supports Accept header too (savanna/utils/api.py:59).

Revision history for this message
Sergey Lukjanov (slukjanov) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to savanna (master)

Reviewed: https://review.openstack.org/35523
Committed: http://github.com/stackforge/savanna/commit/07ccd952cabb050dc89cbe428a1734052480cb06
Submitter: Jenkins
Branch: master

commit 07ccd952cabb050dc89cbe428a1734052480cb06
Author: Matthew Farrellee <email address hidden>
Date: Wed Jul 3 13:58:47 2013 -0400

    Remove dynamic serialization switching

    The code for dynamic serialization switching can be tricked into
    behaving incorrectly. For instance, a request for .../1.1.2 will
    appear to be a request to serialize to troff (".2"). This is not the
    desired behavior.

    The dynamic serialization switching feature should be re-implemented
    at another level of the stack, or should use a different separation
    character, e.g. '?'.

    Fixes: bug #1197479
    Change-Id: I4610b620f52f5eefad65dcbeaa3114bc43547ba2

Changed in savanna:
status: In Progress → Fix Committed
Changed in savanna:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.