yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #45360
[Bug 1537626] [NEW] `glance location-update` deletes locations and backend images
You have been subscribed to a public bug:
Hi all,
I am having trouble using `glance location-update --url <current_url>
--metadata <new_metadata>` to update the metadata of a location. When I
try run the command, the locations become a blank list and the image is
deleted from my backend (swift+https). I have traced it down to the
following:
When doing a location-update, glanceclient actually sends two patch
commands:
[{'op': 'replace', 'path': '/locations', 'value': []},
{'op': 'replace',
'path': '/locations',
'value': [{u'metadata': {u'key': 'value'},
{u'url': u'swift+https://image1'}]}]
This is due to a note in python-glanceclient/glanceclient/v2/images.py,
update_location():
# NOTE: The server (as of now) doesn't support modifying individual
# location entries. So we must:
# 1. Empty existing list of locations.
# 2. Send another request to set 'locations' to the new list
# of locations.
However, at the server end, the _do_replace_locations() function which
handles this call, actually deletes the locations and images when it
gets the first call with the empty values
(glance/glance/api/v2/images.py) ???
def _do_replace_locations(self, image, value):
if len(image.locations) > 0 and len(value) > 0:
msg = _("Cannot replace locations from a non-empty "
"list to a non-empty list.")
raise webob.exc.HTTPBadRequest(explanation=msg)
if len(value) == 0:
# NOTE(zhiyan): this actually deletes the location
# from the backend store.
del image.locations[:]
if image.status == 'active':
image.status = 'queued'
This seems to result in the first call deleting all the locations from
the backend store, and the second call throwing an error because there
is no location any more.
** Affects: glance
Importance: Undecided
Status: New
--
`glance location-update` deletes locations and backend images
https://bugs.launchpad.net/bugs/1537626
You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to Glance.