From a473b688ca5a343d88dbea9cb7dc87cdba010303 Mon Sep 17 00:00:00 2001 From: yhaliaw <43424755+yhaliaw@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:00:22 +0800 Subject: [PATCH] Fix states in get_runners methods --- src-docs/openstack_cloud.openstack_runner_manager.md | 6 +++--- src/manager/github_runner_manager.py | 8 ++++++-- src/openstack_cloud/openstack_runner_manager.py | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src-docs/openstack_cloud.openstack_runner_manager.md b/src-docs/openstack_cloud.openstack_runner_manager.md index f5172cde6..95bf05c5d 100644 --- a/src-docs/openstack_cloud.openstack_runner_manager.md +++ b/src-docs/openstack_cloud.openstack_runner_manager.md @@ -131,7 +131,7 @@ The prefix of runner names. --- - + ### method `cleanup` @@ -184,7 +184,7 @@ Create a self-hosted runner. --- - + ### method `delete_runner` @@ -208,7 +208,7 @@ Delete self-hosted runners. --- - + ### method `flush_runners` diff --git a/src/manager/github_runner_manager.py b/src/manager/github_runner_manager.py index 8f00525b0..686976d84 100644 --- a/src/manager/github_runner_manager.py +++ b/src/manager/github_runner_manager.py @@ -72,12 +72,16 @@ def get_runners( Information on the runners. """ runner_list = self.github.get_runner_github_info(self._path) + runner_list = [runner for runner in runner_list if runner.name.startswith(self._prefix)] + + if states is None: + return tuple(runner_list) + state_set = set(states) return tuple( runner for runner in runner_list - if runner.name.startswith(self._prefix) - and GitHubRunnerManager._is_runner_in_state(runner, state_set) + if GitHubRunnerManager._is_runner_in_state(runner, state_set) ) def delete_runners(self, states: Iterable[GitHubRunnerState] | None = None) -> None: diff --git a/src/openstack_cloud/openstack_runner_manager.py b/src/openstack_cloud/openstack_runner_manager.py index 39475ee69..c84f09d2e 100644 --- a/src/openstack_cloud/openstack_runner_manager.py +++ b/src/openstack_cloud/openstack_runner_manager.py @@ -247,7 +247,9 @@ def get_runners( ] if states is None: return tuple(instance_list) - return tuple(instance for instance in instance_list if instance.state in states) + + state_set = set(states) + return tuple(instance for instance in instance_list if instance.state in state_set) def delete_runner( self, instance_id: InstanceId, remove_token: str