OpenStack Image Management (Glance)
Go to file
Nikhil Komawar 4ac8adbccc Restrict location updates to active, queued images
Currently image location updates (removing, replacing) are permitted for
images even if their state is not ``active``.

This need is to:
 * Prevent the replacement of image locations of images that are not
   ``active`` or ``queued`` by returning a Conflict Error
    (409 response code).
 * Prevent removal of image locations of images that are not ``active``
   by returning a Conflict Error (409 response code).

Changing of image locations when the image state is not ``active`` can
result in bad experiences for the users.
 *  If one tries to change or remove the location for an image while it
    is in ``saving`` state, Glance would be trying to write data to a
    previously saved location while the user updates the custom
    location. This results in a race condition.
 *  For images that are in ``queued`` state and no image data has been
    uploaded yet, there is no need for an image location to be
    removed and permitting users to remove the image
    location can result in a bad experience. However users can be
    allowed to replace the image location to maintain backward
    compatibility and also because replacing could mean replacing an
    empty location by a non-empty image location.
*   For images in ``deactivated`` state, it is essential that image
    locations are not updated as it does not abide with the purpose of
    the image state being set to ``deactivated`` and may cause security
    concerns.

This commit introduces the following change in behavior:
  * If an image is in ``active`` state, removing/replacing the custom
    locations on that image will be allowed so there is no change in
    behavior for this case.
  * If an image is in ``saving`` or ``deactivated``, the status of
    that image will be checked while trying to replace/remove the custom
    location and a HTTP 409 Conflict status will be returned in response
    to the user.
  * If an image is in ``queued`` state, removing the custom
    image location will not be permitted as an image in queued status
    should not have any location associated with it. Replacing of location
    may be permitted here though.
  * If an image is in ``deleted`` or ``pending_delete`` state, a HTTP
    409 Conflict status will be returned, if that image is visible to
    the user (in case of admins). Otherwise, the location cannot be
    removed/replaced anyway.  Please note ``pending_delete`` is another
    form of the ``deleted`` status and behavior in either case should be
    expected to be same.
  * If an image is in ``killed`` status, a HTTP 409 Conflict status will
    be returned.

TODO:
Atomicity is required such that glance permits removal/replacement of
image locations on certain permissible image transition states handling
the race conditions like:
  * In case where the status of the image is ``saving`` and it
    has just moved to ```active`` status, ideally removing/replacing
    custom location should be allowed. However, due to lack of
    atomicity in setting image status glance will ignore setting the
    location and a 409 will be returned.
  * In case where the status of the image is ``deactivated`` and it
    has just been moved to ``active`` status, ideally
    removing/replacing custom location should be allowed. Again, due
    to lack of atomicity in setting image status glance will ignore
    the request and a 409 will be returned.
  * In case where the status of the image is ``active`` and it has
    just been moved to ``deactivated`` status, due to lack of
    atomicity in setting image status, glance may remove/replace
    the location on that image.
  * In case where the status of the image is ``queued`` and it has
    just been moved to ``saving`` status, due to lack of atomicity
    in setting image status, glance may replace the location for
    that image.
  * In case where the status of the image is ``active`` and location
    is attempted to be set on it, and at that point if the image goes
    into ``deleted``, ``pending_delete`` or ``killed`` status, then the
    user must get a HTTP 409 Conflict status. However due to lack of
    atomicity in setting the image status, the location may get updated.

NOTE:
This commit ensures that removal of image locations
is not allowed for an image in any state except ``active`` and
replacement of an image location is not allowed except for ``active``
and ``queued`` images.
Further work is required on the atomicity of glance to accommodate
location updates in cases where the images would be undergoing state
changes.

Impacts:
APIImpact
DocImpact

Credits:
This commit message contains text and information from the commit
message for: https://review.openstack.org/#/c/324012/
co authored by Nikhil Komawar <nik.komawar@gmail.com>.

Co-Authored-By: Nikhil Komawar <nik.komawar@gmail.com>
Co-Authored-By: Dharini Chandrasekar <dharini.chandrasekar@intel.com>

Lite-Spec: https://review.openstack.org/#/c/368192/
Closes-Bug: 1622016

Change-Id: Ic24cf8234599a32add1cb9f294f902e497d885e0
2016-12-05 23:11:10 +00:00
api-ref/source Get ready for os-api-ref sphinx theme change 2016-08-19 16:43:59 +01:00
doc/source Remove DB downgrade 2016-09-01 10:53:08 +08:00
etc Fix a small markup typo 2016-09-03 17:48:50 +05:30
glance Restrict location updates to active, queued images 2016-12-05 23:11:10 +00:00
rally-jobs Merge "Add 'vhdx' disk format." 2016-08-01 18:32:59 +00:00
releasenotes Restrict location updates to active, queued images 2016-12-05 23:11:10 +00:00
.coveragerc Change ignore-errors to ignore_errors 2015-09-21 14:26:41 +00:00
.gitignore Add reno for release notes management 2015-11-04 18:21:25 +00:00
.gitreview Add .gitreview config file for gerrit. 2011-10-24 11:02:16 -04:00
.mailmap Add a mailmap entry for myself 2014-02-11 12:00:44 +08:00
.testr.conf Switch to testrepository for running tests 2014-01-29 08:30:55 +08:00
CONTRIBUTING.rst Update to Glance Contributor's docs 2016-06-29 18:17:53 -04:00
HACKING.rst Corrected section underline 2016-04-15 11:40:59 +05:30
LICENSE Add a LICENSE file. 2012-01-03 10:14:01 -05:00
MANIFEST.in Remove old traces of the oslo-incubator 2015-09-09 09:11:05 +02:00
README.rst Fix rendering of readme document 2015-01-07 11:07:06 +00:00
babel.cfg Added first step of babel-based translations. 2012-02-28 02:00:37 -08:00
bandit.yaml Move bandit into pep8 2016-02-26 08:12:45 +01:00
pylintrc Typo in pylintrc file 2015-03-25 11:21:16 +01:00
requirements.txt Merge "Use cursive for signature verification" 2016-09-01 03:34:09 +00:00
setup.cfg revert warnerrors before gate breaks 2016-03-14 09:17:13 -04:00
setup.py Updated from global requirements 2015-09-24 01:01:31 +00:00
test-requirements.txt Updated from global requirements 2016-08-31 18:24:10 +00:00
tox.ini WADL to RST migration (part 1) 2016-06-21 13:29:24 -04:00

README.rst

Glance

Glance is a project that defines services for discovering, registering, retrieving and storing virtual machine images.

Use the following resources to learn more: