Updated openstack/openstack
Project: openstack/glance  0d95e5316a99b78b4f629a29d862548f87671b43

Allow some property operations when quota exceeded

Currently in Glance v2 if, for some reason, an image has more
properties than the image_propery_quota allows (e.g. the quota was
lowered after the image was created with properties) then any request
to modify or delete existing properties results in a 413 overlimit
error. Ideally a user should be able to remove properties or any other
action except for adding a property when they are over their quota for
a given image.

This commit does this by adding a new member to the quota.ImageProxy
class to "remember" what properties were already present in an image
*before* any new property operations are preformed on the image. After
the new property operations are performed the quotas are checked (before
writing the image info to DB) only if any new properties have been
added.

This commit does not use a subclass of ExtraPropertiesProxy to check
property quotas (in the __setitem__ method) because Glance does not
implement the JSON-patch RFC correctly - in Glance all operations in a
patch are applied and the quota checked only after all operations have
been applied (RFC requires that operations be applied sequentially and
fail on the first failure). Therefore it is possible for the quota to be
temporarily exceeded when a patch is being applied and therefore we
cannot check for quotas as they are being added - we have to wait until
all patch operations have been completed.

Also, as per review discussions in IRC, a new file:
    glance/tests/integration/v2/test_property_quota_violations.py
has been added to perform image property quota related tests (because
the functional test framework is slow).

Change-Id: Icf1b46343463791ed3d2f3ce376f11e409e792ff
Closes-bug: #1258331
Author: David Koo <david.koo@huawei.com>