Skip to content

Commit

Permalink
Fix flavor naming
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw committed Aug 28, 2024
1 parent 19b1a38 commit dab5611
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src-docs/openstack_cloud.openstack_runner_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Manage self-hosted runner on OpenStack cloud.

```python
__init__(
manager_name: str,
prefix: str,
cloud_config: OpenStackCloudConfig,
server_config: OpenStackServerConfig | None,
Expand All @@ -109,6 +110,7 @@ Construct the object.

**Args:**

- <b>`manager_name`</b>: A name to identify this manager.
- <b>`prefix`</b>: The prefix to runner name.
- <b>`cloud_config`</b>: The configuration for OpenStack authorisation.
- <b>`server_config`</b>: The configuration for creating OpenStack server. Unable to create runner if None.
Expand All @@ -131,7 +133,7 @@ The prefix of runner names.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L308"><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#L311"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

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

Expand All @@ -154,7 +156,7 @@ Cleanup runner and resource on the cloud.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L158"><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#L161"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `create_runner`

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

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L257"><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#L260"><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 +210,7 @@ Delete self-hosted runners.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L283"><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#L286"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

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

Expand All @@ -231,7 +233,7 @@ Remove idle and/or busy runners.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L203"><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#L206"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_runner`

Expand All @@ -254,7 +256,7 @@ Get a self-hosted runner by instance id.

---

<a href="../src/openstack_cloud/openstack_runner_manager.py#L225"><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#L228"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_runners`

Expand Down
1 change: 1 addition & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,7 @@ def _get_runner_scaler(
)
# The prefix is set to f"{application_name}-{unit number}"
openstack_runner_manager = OpenStackRunnerManager(
manager_name=self.app.name,
prefix=self.unit.name.replace("/", "-"),
cloud_config=cloud_config,
server_config=server_config,
Expand Down
5 changes: 4 additions & 1 deletion src/openstack_cloud/openstack_runner_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class OpenStackRunnerManager(CloudRunnerManager):
# Ignore "Too many arguments", as the class requires a lot of configurations.
def __init__( # pylint: disable=R0913
self,
manager_name: str,
prefix: str,
cloud_config: OpenStackCloudConfig,
server_config: OpenStackServerConfig | None,
Expand All @@ -128,13 +129,15 @@ def __init__( # pylint: disable=R0913
"""Construct the object.
Args:
manager_name: A name to identify this manager.
prefix: The prefix to runner name.
cloud_config: The configuration for OpenStack authorisation.
server_config: The configuration for creating OpenStack server. Unable to create
runner if None.
runner_config: The configuration for the runner.
service_config: The configuration of supporting services of the runners.
"""
self._manager_name = manager_name
self._prefix = prefix
self._cloud_config = cloud_config
self._server_config = server_config
Expand Down Expand Up @@ -194,7 +197,7 @@ def create_runner(self, registration_token: str) -> InstanceId:
end_timestamp = time.time()
OpenStackRunnerManager._issue_runner_installed_metric(
name=instance_name,
flavor=self.name_prefix,
flavor=self._manager_name,
install_start_timestamp=start_timestamp,
install_end_timestamp=end_timestamp,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_runner_manager_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def openstack_runner_manager_fixture(
repo_policy_compliance=None,
)
return OpenStackRunnerManager(
app_name, cloud_config, server_config, runner_config, service_config
app_name, f"{app_name}-0", cloud_config, server_config, runner_config, service_config
)


Expand Down

0 comments on commit dab5611

Please sign in to comment.