Public bug reported: "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 ** Affects: glance Importance: Undecided Status: New -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to Glance. https://bugs.launchpad.net/bugs/1847188 Title: Glance import image using web-download fails Status in Glance: New 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 To manage notifications about this bug go to: https://bugs.launchpad.net/glance/+bug/1847188/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

