Duplicate entry for image_location

Bug #1205006 reported by Stuart McLaren
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
In Progress
Wishlist
Unassigned

Bug Description

Latest devstack:

1) create an image

$ glance image-create --name s2
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | None |
| created_at | 2013-07-25T16:55:46 |
| deleted | False |
| deleted_at | None |
| disk_format | None |
| id | 2e1883ee-1b2d-417d-bc81-4d5edf306e2b |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | s2 |
| owner | ecc4670241e842c991b8737802468e20 |
| protected | False |
| size | 0 |
| status | queued |
| updated_at | 2013-07-25T16:55:46 |
+------------------+--------------------------------------+

2) set the location parameter

$ glance image-update 2e1883ee-1b2d-417d-bc81-4d5edf306e2b --location 'swift+http://service%3Aglance:<pw>@10.6.101.232:5000/v2.0/glance/aaa' --disk-format raw --container-format bare
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | bare |
| created_at | 2013-07-25T16:55:46 |
| deleted | False |
| deleted_at | None |
| disk_format | raw |
| id | 2e1883ee-1b2d-417d-bc81-4d5edf306e2b |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | s2 |
| owner | ecc4670241e842c991b8737802468e20 |
| protected | False |
| size | 0 |
| status | active |
| updated_at | 2013-07-25T16:56:19 |
+------------------+--------------------------------------+

there are two entries with the specified location in the database (once of which is deleted)

ubuntu@devstack24:~$ mysql -uroot -p <passwd> -h localhost glance -e 'select * from image_locations where image_id="2e1883ee-1b2d-417d-bc81-4d5edf306e2b"'
+----+--------------------------------------+--------------------------------------------------------------------------+---------------------+---------------------+---------------------+---------+-----------+
| id | image_id | value | created_at | updated_at | deleted_at | deleted | meta_data |
+----+--------------------------------------+--------------------------------------------------------------------------+---------------------+---------------------+---------------------+---------+-----------+
| 10 | 2e1883ee-1b2d-417d-bc81-4d5edf306e2b | swift+http://service%3Aglance:<pw>@10.6.101.232:5000/v2.0/glance/aaa | 2013-07-25 16:56:19 | 2013-07-25 16:56:19 | 2013-07-25 16:56:19 | 1 | €}q. |
| 11 | 2e1883ee-1b2d-417d-bc81-4d5edf306e2b | swift+http://service%3Aglance:<pw>@10.6.101.232:5000/v2.0/glance/aaa | 2013-07-25 16:56:19 | 2013-07-25 16:56:19 | NULL | 0 | €}q. |
+----+--------------------------------------+--------------------------------------------------------------------------+---------------------+---------------------+---------------------+---------+-----------+

description: updated
Revision history for this message
Feilong Wang (flwang) wrote :

I can recreate this issue.

Changed in glance:
status: New → Confirmed
Revision history for this message
yong sheng gong (gongysh) wrote :

-> return func(self, req, *args, **kwargs)
  /opt/stack/glance/glance/api/v1/images.py(686)update()
-> purge_props)
  /opt/stack/glance/glance/registry/client/v1/api.py(194)update_image_metadata()
-> return c.update_image(image_id, image_meta, purge_props)
> /opt/stack/glance/glance/registry/client/v1/client.py(158)update_image()
-> encrypted_metadata = self.encrypt_metadata(image_metadata['image'])

  /opt/stack/glance/glance/api/v1/images.py(690)update()
-> image_data)
  /opt/stack/glance/glance/api/v1/images.py(535)_handle_source()
-> image_meta = self._activate(req, image_id, location)
  /opt/stack/glance/glance/api/v1/images.py(474)_activate()
-> image_meta)
  /opt/stack/glance/glance/registry/client/v1/api.py(194)update_image_metadata()
-> return c.update_image(image_id, image_meta, purge_props)
> /opt/stack/glance/glance/registry/client/v1/client.py(158)update_image()
-> encrypted_metadata = self.encrypt_metadata(image_metadata['image'])

the registry is called twice:
one is pure update, and then activate()

Changed in glance:
assignee: nobody → Tushar Bankar (tushar-bankar)
Revision history for this message
Zhi Yan Liu (lzy-dev) wrote :

Actually this is not a defect but an improvement. From DB you can see the original location be marked to "deleted" status. Since under current sqlalchemy db driver implementation [1], glance delete all "original" image's location entries first then to re-add "new" entries.

[1] https://github.com/openstack/glance/blob/master/glance/db/sqlalchemy/api.py#L859

Revision history for this message
Tushar Bankar (tushar-bankar) wrote :

If the glance image update api is called and a new image location url is specified, the old locations are soft deleted and new locations are added to db, but this should not happen if both old and new locations are same urls, hence we need to fix this issue

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

Fix proposed to branch: master
Review: https://review.openstack.org/80494

Changed in glance:
status: Confirmed → In Progress
Zhi Yan Liu (lzy-dev)
Changed in glance:
importance: Undecided → Wishlist
Revision history for this message
Tushar Bankar (tushar-bankar) wrote :

The fix for this Bug is covered in BP (https://blueprints.launchpad.net/glance/+spec/image-location-status). Hence abandoning.

Changed in glance:
assignee: Tushar Bankar (tushar-bankar) → nobody
Revision history for this message
Viktor Serhieiev (vsergeyev) wrote :

Blueprint image-location-status was already implemented. Should we mark this bug as fixed?

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.