Simplify _deleteLocalBuild parameters

Both parameters being passed in are coming from the same object,
so just pass in the object itself.

Change-Id: Ie9d78a1d884764a25fce881282bf15bc662e15e5
This commit is contained in:
David Shrewsbury 2017-07-17 09:05:37 -04:00
parent 1f175a4754
commit 42e15e2150

View File

@ -221,27 +221,26 @@ class CleanupWorker(BaseWorker):
if e.errno != 2: # No such file or directory
raise e
def _deleteLocalBuild(self, image, build_id, builder):
def _deleteLocalBuild(self, image, build):
'''
Remove expired image build from local disk.
:param str image: Name of the image whose build we are deleting.
:param str build_id: ID of the build we want to delete.
:param str builder: hostname of the build.
:param ImageBuild build: The build we want to delete.
:returns: True if files were deleted, False if none were found.
'''
base = "-".join([image, build_id])
base = "-".join([image, build.id])
files = DibImageFile.from_image_id(self._config.imagesdir, base)
if not files:
# NOTE(pabelanger): It is possible we don't have any files because
# diskimage-builder failed. So, check to see if we have the correct
# builder so we can removed the data from zookeeper.
if builder == self._hostname:
if build.builder == self._hostname:
return True
return False
self.log.info("Doing cleanup for %s:%s" % (image, build_id))
self.log.info("Doing cleanup for %s:%s" % (image, build.id))
manifest_dir = None
@ -468,7 +467,7 @@ class CleanupWorker(BaseWorker):
self._zk.storeBuild(image, build, build.id)
# Release the lock here so we can delete the build znode
if self._deleteLocalBuild(image, build.id, build.builder):
if self._deleteLocalBuild(image, build):
if not self._zk.deleteBuild(image, build.id):
self.log.error("Unable to delete build %s because"
" uploads still remain.", build)