Skip to content

Commit 54d548b

Browse files
authored
chore: rename cleanup function (#605)
* chore: rename cleanup function * test: update cleanup function name * chore: remove unused import
1 parent de0b4f7 commit 54d548b

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

github-runner-manager/src/github_runner_manager/openstack_cloud/openstack_cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def get_instances(self) -> tuple[OpenstackInstance, ...]:
532532
)
533533

534534
@_catch_openstack_errors
535-
def cleanup(self) -> None:
535+
def delete_expired_keys(self) -> None:
536536
"""Cleanup unused key files and openstack keypairs."""
537537
with self._get_openstack_connection() as conn:
538538
instances = self._get_openstack_instances(conn)

github-runner-manager/src/github_runner_manager/openstack_cloud/openstack_runner_manager.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import logging
77
import secrets
8-
from dataclasses import dataclass
98
from pathlib import Path
109
from typing import Sequence
1110

@@ -47,25 +46,6 @@
4746
OUTDATED_METRICS_STORAGE_IN_SECONDS = CREATE_SERVER_TIMEOUT + 30 # add a bit on top of the timeout
4847

4948

50-
class _GithubRunnerRemoveError(Exception):
51-
"""Represents an error while SSH into a runner and running the remove script."""
52-
53-
54-
@dataclass
55-
class _RunnerHealth:
56-
"""Runners with health state.
57-
58-
Attributes:
59-
healthy: The list of healthy runners.
60-
unhealthy: The list of unhealthy runners.
61-
unknown: The list of runners whose health state could not be determined.
62-
"""
63-
64-
healthy: tuple[OpenstackInstance, ...]
65-
unhealthy: tuple[OpenstackInstance, ...]
66-
unknown: tuple[OpenstackInstance, ...]
67-
68-
6949
class OpenStackRunnerManager(CloudRunnerManager):
7050
"""Manage self-hosted runner on OpenStack cloud.
7151
@@ -158,7 +138,7 @@ def get_runners(self) -> Sequence[CloudRunnerInstance]:
158138

159139
def cleanup(self) -> None:
160140
"""Cleanup runner and resource on the cloud."""
161-
self._openstack_cloud.cleanup()
141+
self._openstack_cloud.delete_expired_keys()
162142

163143
def _build_cloud_runner_instance(self, instance: OpenstackInstance) -> CloudRunnerInstance:
164144
"""Build a new cloud runner instance from an openstack instance."""

github-runner-manager/tests/unit/openstack_cloud/test_openstack_cloud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def mock_openstack_conn_fixture(monkeypatch: pytest.MonkeyPatch):
8585
),
8686
pytest.param("get_instance", {"instance_id": FAKE_ARG}, id="get_instance"),
8787
pytest.param("get_instances", {}, id="get_instances"),
88-
pytest.param("cleanup", {}, id="cleanup"),
88+
pytest.param("delete_expired_keys", {}, id="delete_expired_keys"),
8989
],
9090
)
9191
def test_raises_openstack_error(
@@ -237,7 +237,7 @@ def test_keypair_cleanup_freshly_created_keypairs(
237237
openstack_connect_mock.return_value = openstack_connection_mock
238238

239239
# act #
240-
openstack_cloud.cleanup()
240+
openstack_cloud.delete_expired_keys()
241241

242242
# assert #
243243
# Check if only the old keypairs are deleted

0 commit comments

Comments
 (0)