glance image-import command fails with 500 error

Bug #1708702 reported by Brian Rosmaita
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Critical
Unassigned

Bug Description

This was reported by Abhishek Kekane.

Steps to reproduce:
1. Run glance image-import <image-id> or curl -g -i -X POST http://10.232.48.204/image/v2/images/6d5851f8-bdd2-43d0-a3ee-3b4017e31b45/import -H "User-Agent: python-glanceclient" -H "Content-Type: application/json" -H "X-Auth-Token: {SHA1}462b312cf75dd125706dd13acb7cbbc3eb244ca2" -d '{"import_method": "glance-direct"}'

Reason:
1. We are passing body to post url but the controller method does not accepts body parameter. So wsgi throws error import_image() has got invalid keyword argument 'body'.

Need to make below changes in /glance/api/v2/images.py
--- a/glance/api/v2/images.py
+++ b/glance/api/v2/images.py
@@ -89,11 +89,12 @@ class ImagesController(object):
         return image

     @utils.mutating
- def import_image(self, req, image):
+ def import_image(self, req, image_id, body):
         task_factory = self.gateway.get_task_factory(req.context)
         executor_factory = self.gateway.get_task_executor_factory(req.context)
         task_repo = self.gateway.get_task_repo(req.context)

         task_input = {}

         try:
@@ -108,7 +109,7 @@ class ImagesController(object):
             LOG.debug("User not permitted to create image import task.")
             raise webob.exc.HTTPForbidden(explanation=e.msg)

- return image
+ return image_id

Other problems:
1. image_id is not used anywhere
2. "import_method" passed in body is not used anywhere.

Changed in glance:
importance: Undecided → Critical
Revision history for this message
Brian Rosmaita (brian-rosmaita) wrote :

> Other problems:
> 1. image_id is not used anywhere
> 2. "import_method" passed in body is not used anywhere.

With respect to #2, we only have one import method at this point, so I think that's OK.

With respect to #1, somehow the image_id needs to get over to the task, I don't see how that's happening ATM.

> - return image
> + return image_id

This change makes sense since we don't actually have an image available. On the other hand, this call is supposed to return a 202 (Accepted). Do we need to add an image_import(self, response, result) method to the ResponseSerializer (just like the one that's currently there for delete)?

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

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

Changed in glance:
status: Triaged → In Progress
Changed in glance:
assignee: Brian Rosmaita (brian-rosmaita) → nobody
Changed in glance:
milestone: pike-rc1 → pike-rc2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/491249
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=d4917cf606e99429e019538cd95f06ab0673acca
Submitter: Jenkins
Branch: master

commit d4917cf606e99429e019538cd95f06ab0673acca
Author: Brian Rosmaita <email address hidden>
Date: Sun Aug 6 11:16:25 2017 -0400

    Fix 500 error from image-import call

    This patch modifies the images controller to accept a body (which
    is required) for the image import call and cleans up a bit around
    the request deserialization/response serialization.

    Co-authored-by: Abhishek Kekane <email address hidden>
    Co-authored-by: Brian Rosmaita <email address hidden>

    Change-Id: I08783e28719e63b5a4b2115b8fce135e55be460a
    Closes-bug: #1708702

Changed in glance:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/495789

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on glance (stable/pike)

Change abandoned by Abhishek Kekane (<email address hidden>) on branch: stable/pike
Review: https://review.openstack.org/495789
Reason: Abandoning as we are reverting this change on master.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (stable/pike)

Reviewed: https://review.openstack.org/495789
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=c99a9c96b1b8165fbb10317e39a8256ce4c1c6c2
Submitter: Jenkins
Branch: stable/pike

commit c99a9c96b1b8165fbb10317e39a8256ce4c1c6c2
Author: Brian Rosmaita <email address hidden>
Date: Sun Aug 6 11:16:25 2017 -0400

    Fix 500 error from image-import call

    This patch modifies the images controller to accept a body (which
    is required) for the image import call and cleans up a bit around
    the request deserialization/response serialization.

    Co-authored-by: Abhishek Kekane <email address hidden>
    Co-authored-by: Brian Rosmaita <email address hidden>

    Change-Id: I08783e28719e63b5a4b2115b8fce135e55be460a
    Closes-bug: #1708702
    (cherry picked from commit d4917cf606e99429e019538cd95f06ab0673acca)

tags: added: in-stable-pike
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/glance 15.0.0.0rc2

This issue was fixed in the openstack/glance 15.0.0.0rc2 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/glance 16.0.0.0b1

This issue was fixed in the openstack/glance 16.0.0.0b1 development milestone.

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.