Skip to content
Snippets Groups Projects
Commit 3a037888 authored by zphrs's avatar zphrs
Browse files

Minor perf improvements

parent 4618a03b
No related branches found
No related tags found
No related merge requests found
...@@ -107,7 +107,7 @@ class ClusterConductor: ...@@ -107,7 +107,7 @@ class ClusterConductor:
def dump_all_container_logs(self, dir): def dump_all_container_logs(self, dir):
self.log("dumping logs of kvs containers") self.log("dumping logs of kvs containers")
container_pattern = "^kvs_.*" container_pattern = f"^kvs_{self.group_id}_.*"
container_regex = re.compile(container_pattern) container_regex = re.compile(container_pattern)
containers = self._list_containers() containers = self._list_containers()
...@@ -143,6 +143,17 @@ class ClusterConductor: ...@@ -143,6 +143,17 @@ class ClusterConductor:
error_prefix=f"failed to remove container {name}", error_prefix=f"failed to remove container {name}",
) )
def _remove_containers(self, names: list[str]) -> None:
if len(names) == 0:
return
self.log(f"removing containers {names}")
run_cmd_bg(
self._make_remove_cmd(names[0]) + names[1:],
verbose=True,
error_prefix=f"failed to remove containers {names}",
)
def _remove_network(self, name: str) -> None: def _remove_network(self, name: str) -> None:
# remove a single network # remove a single network
self.log(f"removing network {name}") self.log(f"removing network {name}")
...@@ -184,10 +195,12 @@ class ClusterConductor: ...@@ -184,10 +195,12 @@ class ClusterConductor:
# cleanup containers # cleanup containers
self.log(f" cleaning up {'group' if group_only else 'all'} containers") self.log(f" cleaning up {'group' if group_only else 'all'} containers")
containers = self._list_containers() containers = self._list_containers()
for container in containers: containers_to_remove = [
if container and container_regex.match(container): container
self._remove_container(container) for container in containers
if container and container_regex.match(container)
]
self._remove_containers(containers_to_remove)
# cleanup networks # cleanup networks
self.log(f" cleaning up {'group' if group_only else 'all'} networks") self.log(f" cleaning up {'group' if group_only else 'all'} networks")
networks = self._list_networks() networks = self._list_networks()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment