Glance import image using web-download fails

Bug #1847188 reported by Hiroyuki Jo on 2019-10-08
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance
Undecided
Unassigned

Bug Description

"Web-Download" method for image uploading stacks and never end. I confirmed the bug using the master repository that includes the following patches.
  2019-09-12 Images API version bump and config sync

[procedure]
0.As a prerequisite, an http server is set up on localhost, and the image file can be downloaded from the following URI.
http://127.0.0.1:8000/cirros-0.4.0-x86_64-disk.img

1.Create image.
$ openstack image create sample-web-image
+------------------+--------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------+
| checksum | None |
| container_format | bare |
| created_at | 2019-10-07T06:37:28Z |
| disk_format | raw |
| file | /v2/images/2f3151a3-d068-4128-ad8b-6e62edc9b175/file |
| id | 2f3151a3-d068-4128-ad8b-6e62edc9b175 |
| min_disk | 0 |
| min_ram | 0 |
| name | sample-web-image |
| owner | aadfce81cd1247a397f4fa1e0344c478 |
| properties | os_hash_algo='None', os_hash_value='None', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | None |
| status | queued |
| tags | |
| updated_at | 2019-10-07T06:37:28Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------+

2.Set environment variables.
$ openstack token issue

| id | xxx

$ export token=xxx
$ export image_url=http://127.0.0.1/image
$ export image_id=2f3151a3-d068-4128-ad8b-6e62edc9b175

3.Import image using web-download.
$ cat req-body.json
{
    "method": {
        "name": "web-download",
        "uri": "http://127.0.0.1:8000/cirros-0.4.0-x86_64-disk.img"
    }
}
$ curl -X POST -H "X-Auth-Token: $token" -H "Content-Type: application/json" -d @req-body.json $image_url/v2/images/$image_id/import

4.Check image status
$ openstack image list

| 2f3151a3-d068-4128-ad8b-6e62edc9b175 | sample-web-image | queued |

No error has occurred in the Glance log, but the process seems stuck and the status never transition from queued.

This is because there is no context switch from parent thread to a green thread used to image download.
For your reference, I pasted a changes to fix the bug. Please examine it.
Also, see best practice about eventlet in OpenStack for a reference.
https://specs.openstack.org/openstack/openstack-specs/specs/eventlet-best-practices.html

$ git diff
diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py
index 811cca8..1e129f6 100644
--- a/glance/common/wsgi.py
+++ b/glance/common/wsgi.py
@@ -37,6 +37,7 @@ from eventlet.green import socket
 from eventlet.green import ssl
 import eventlet.greenio
 import eventlet.wsgi
+eventlet.monkey_patch()
 import glance_store
 from os_win import utilsfactory as os_win_utilsfactory
 from oslo_concurrency import processutils

Erno Kuvaja (jokke) on 2019-11-18
Changed in glance:
status: New → Incomplete
Erno Kuvaja (jokke) wrote :

Hi Hiroyuki,

Thanks for the detailed bug description. Could you please confirm couple of details for us:
How is your glance-api deployed and started? (Devstack, under mod_wsgi, uwsgi, or pure eventlet app?)
Is this bug surfacing always, py2.7 or py3?

Hiroyuki Jo (joxyuki) wrote :

Hi Erno,
I deployed all my openstack project using devstack and py2.7.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers