diff options
author | Hemanth Makkapati <hemanth.makkapati@rackspace.com> | 2015-02-24 18:08:46 -0500 |
---|---|---|
committer | Hemanth Makkapati <hemanth.makkapati@rackspace.com> | 2015-03-03 14:59:41 -0500 |
commit | 9221e44182dee1198e323e91a78c157988f99fda (patch) | |
tree | 21a1977eceecbfd0bdf7c5c86d8a539138ad42b4 /glance_store/_drivers | |
parent | 43c084a336d7bc224443903089be8dc2aa14dd13 (diff) | |
download | glance_store-9221e44182dee1198e323e91a78c157988f99fda.tar.gz |
Support for deleting images stored as SLO in Swift
When an image is deleted, the image data is not being deleted
completely if it is stored as static large object(SLO). Only the
manifest is deleted leaving behind all the segments. This leads to
stale data in swift cluster.
This change attempts to delete the SLO in the following way:
1. Identify a SLO with 'x-static-large-object' header on an object
2. Delete the SLO, both manifest and the segments, using the
query string 'multipart-manifest=delete' while deleting the object
Closes-Bug: 1425617
Change-Id: Id2cd3b63ca88d66c5e7435b528ba75fa3c2cbb1c
Diffstat (limited to 'glance_store/_drivers')
-rw-r--r-- | glance_store/_drivers/swift/store.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/glance_store/_drivers/swift/store.py b/glance_store/_drivers/swift/store.py index 9f1995c..30b69f3 100644 --- a/glance_store/_drivers/swift/store.py +++ b/glance_store/_drivers/swift/store.py @@ -22,6 +22,7 @@ import math from oslo.config import cfg from oslo.utils import excutils +import six import six.moves.urllib.parse as urlparse import swiftclient import urllib @@ -373,6 +374,14 @@ def Store(conf): Store.OPTIONS = _SWIFT_OPTS + sutils.swift_opts +def _is_slo(slo_header): + if (slo_header is not None and isinstance(slo_header, six.string_types) + and slo_header.lower() == 'true'): + return True + + return False + + class BaseStore(driver.Store): _CAPABILITIES = capabilities.BitMasks.RW_ACCESS @@ -612,17 +621,27 @@ class BaseStore(driver.Store): # that means the object was uploaded in chunks/segments, # and we need to delete all the chunks as well as the # manifest. - manifest = None + dlo_manifest = None + slo_manifest = None try: headers = connection.head_object( location.container, location.obj) - manifest = headers.get('x-object-manifest') + dlo_manifest = headers.get('x-object-manifest') + slo_manifest = headers.get('x-static-large-object') except swiftclient.ClientException as e: if e.http_status != httplib.NOT_FOUND: raise - if manifest: + + if _is_slo(slo_manifest): + # Delete the manifest as well as the segments + query_string = 'multipart-manifest=delete' + connection.delete_object(location.container, location.obj, + query_string=query_string) + return + + if dlo_manifest: # Delete all the chunks before the object manifest itself - obj_container, obj_prefix = manifest.split('/', 1) + obj_container, obj_prefix = dlo_manifest.split('/', 1) segments = connection.get_container( obj_container, prefix=obj_prefix)[1] for segment in segments: |