Skip to content

Commit

Permalink
Fix states in get_runners methods
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw committed Aug 27, 2024
1 parent 7c5a78e commit a473b68
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src-docs/openstack_cloud.openstack_runner_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ The prefix of runner names.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L303"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_runner_manager.py#L305"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `cleanup`

Expand Down Expand Up @@ -184,7 +184,7 @@ Create a self-hosted runner.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L252"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_runner_manager.py#L254"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `delete_runner`

Expand All @@ -208,7 +208,7 @@ Delete self-hosted runners.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L278"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/openstack_cloud/openstack_runner_manager.py#L280"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `flush_runners`

Expand Down
8 changes: 6 additions & 2 deletions src/manager/github_runner_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/openstack_cloud/openstack_runner_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a473b68

Please sign in to comment.