summaryrefslogtreecommitdiffstats
path: root/gluster/swift/obj/expirer.py
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2016-04-20 15:10:43 +0530
committerThiago da Silva <thiago@redhat.com>2016-04-20 12:08:03 -0700
commit5a04cede1f5bb44d6c64b186335146dd4e70a6ea (patch)
tree34babe4bcc295562ca3b740c98bc2299669c12f3 /gluster/swift/obj/expirer.py
parent2bd696e392e420a2521dcca0b8613122d8169025 (diff)
Make swift's expirer compatible with gluster-swift
Swift's object expirer in kilo series was incompatible with gluster-swift. This change does the following: * Optimizes crawl in account and container server for listing requests for containers and tracker objects in gsexpiring volume. * Enables container server to delete tracker objects from gsexpiring volume. Swift's expirer sends request directly to container server to remove tracker object entry. * delete_tracker_object() is now a common utility function that is invoked from container server and gluster-swift's object expirer. * Run functional test to be run against both swift's object expirer and gluster-swift's object expirer Change-Id: Ib5b7f7f08fe7dda574f6dd80be2f38bdfaee32bc Signed-off-by: Prashanth Pai <ppai@redhat.com> Reviewed-on: http://review.gluster.org/14038 Reviewed-by: Thiago da Silva <thiago@redhat.com> Tested-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'gluster/swift/obj/expirer.py')
-rw-r--r--gluster/swift/obj/expirer.py40
1 files changed, 6 insertions, 34 deletions
diff --git a/gluster/swift/obj/expirer.py b/gluster/swift/obj/expirer.py
index 564a2c9..38f870e 100644
--- a/gluster/swift/obj/expirer.py
+++ b/gluster/swift/obj/expirer.py
@@ -20,7 +20,7 @@ import gluster.swift.common.constraints # noqa
import errno
import os
-from gluster.swift.common.utils import rmobjdir
+from gluster.swift.common.utils import delete_tracker_object
from swift.obj.expirer import ObjectExpirer as SwiftObjectExpirer
from swift.common.http import HTTP_NOT_FOUND
@@ -95,45 +95,17 @@ class ObjectExpirer(SwiftObjectExpirer):
# which has a threadpool of 20 threads (default)
self.threadpool = ThreadPool(nthreads=0)
- def _delete_tracker_object(self, container, obj):
- container_path = os.path.join(self.devices,
- self.expiring_objects_account,
- container)
- tracker_object_path = os.path.join(container_path, obj)
-
- try:
- os.unlink(tracker_object_path)
- except OSError as err:
- if err.errno in (errno.ENOENT, errno.ESTALE):
- # Ignore removal from another entity.
- return
- elif err.errno == errno.EISDIR:
- # Handle race: Was a file during crawl, but now it's a
- # directory. There are no 'directory marker' objects in
- # gsexpiring volume.
- return
- else:
- raise
-
- # This part of code is very similar to DiskFile._unlinkold()
- dirname = os.path.dirname(tracker_object_path)
- while dirname and dirname != container_path:
- if not rmobjdir(dirname, marker_dir_check=False):
- # If a directory with objects has been found, we can stop
- # garbage collection
- break
- else:
- # Traverse upwards till the root of container
- dirname = os.path.dirname(dirname)
-
def pop_queue(self, container, obj):
"""
In Swift, this method removes tracker object entry directly from
container database. In gluster-swift, this method deletes tracker
object directly from filesystem.
"""
- self.threadpool.force_run_in_thread(self._delete_tracker_object,
- container, obj)
+ container_path = os.path.join(self.devices,
+ self.expiring_objects_account,
+ container)
+ self.threadpool.force_run_in_thread(delete_tracker_object,
+ container_path, obj)
def delete_actual_object(self, actual_obj, timestamp):
"""