From 42e15e21505b0f91fb4b0d82684fb2dcf2d823e2 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Mon, 17 Jul 2017 09:05:37 -0400 Subject: [PATCH] Simplify _deleteLocalBuild parameters Both parameters being passed in are coming from the same object, so just pass in the object itself. Change-Id: Ie9d78a1d884764a25fce881282bf15bc662e15e5 --- nodepool/builder.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/nodepool/builder.py b/nodepool/builder.py index 06c82d469..76013e77d 100644 --- a/nodepool/builder.py +++ b/nodepool/builder.py @@ -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)