From 9b48b17eddea5e366e0c59ed9f3540793550256c Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 2 Nov 2015 15:53:05 -0500 Subject: [PATCH] 7444: Rename kwarg remove_stopped_containers -> remove_containers_onexit --- services/dockercleaner/arvados_docker/cleaner.py | 11 +++++------ services/dockercleaner/tests/test_cleaner.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/services/dockercleaner/arvados_docker/cleaner.py b/services/dockercleaner/arvados_docker/cleaner.py index f9d727f2ec..2435e6de80 100755 --- a/services/dockercleaner/arvados_docker/cleaner.py +++ b/services/dockercleaner/arvados_docker/cleaner.py @@ -177,10 +177,10 @@ class DockerImageUseRecorder(DockerEventListener): class DockerImageCleaner(DockerImageUseRecorder): event_handlers = DockerImageUseRecorder.event_handlers.copy() - def __init__(self, images, docker_client, events, remove_stopped_containers=False): + def __init__(self, images, docker_client, events, remove_containers_onexit=False): super().__init__(images, docker_client, events) self.logged_unknown = set() - self.remove_stopped_containers = remove_stopped_containers + self.remove_containers_onexit = remove_containers_onexit def new_container(self, event, container_hash): container_image_id = container_hash['Image'] @@ -199,9 +199,8 @@ class DockerImageCleaner(DockerImageUseRecorder): @event_handlers.on('die') def clean_container(self, event=None): - if not self.remove_stopped_containers: - return - self._remove_container(event['id']) + if self.remove_containers_onexit: + self._remove_container(event['id']) def check_stopped_containers(self, remove=False): logger.info("Checking for stopped containers") @@ -278,7 +277,7 @@ def run(args, docker_client): use_recorder.run() cleaner = DockerImageCleaner( images, docker_client, docker_client.events(since=start_time), - remove_stopped_containers=args.remove_stopped_containers != 'never') + remove_containers_onexit=args.remove_stopped_containers != 'never') cleaner.check_stopped_containers( remove=args.remove_stopped_containers == 'always') logger.info("Checking image quota at startup") diff --git a/services/dockercleaner/tests/test_cleaner.py b/services/dockercleaner/tests/test_cleaner.py index a9ecc92441..43abe4f636 100644 --- a/services/dockercleaner/tests/test_cleaner.py +++ b/services/dockercleaner/tests/test_cleaner.py @@ -313,7 +313,7 @@ class DockerImageCleanerTestCase(DockerImageUseRecorderTestCase): class DockerContainerCleanerTestCase(DockerImageUseRecorderTestCase): TEST_CLASS = cleaner.DockerImageCleaner - TEST_CLASS_INIT_KWARGS = {'remove_stopped_containers': True} + TEST_CLASS_INIT_KWARGS = {'remove_containers_onexit': True} @mock.patch('arvados_docker.cleaner.logger') def test_failed_container_deletion_handling(self, mockLogger): -- 2.30.2