Skip to content

Commit

Permalink
revert using class in reactive runner manager
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartz committed Jul 8, 2024
1 parent 6839b76 commit 22d5561
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 186 deletions.
83 changes: 42 additions & 41 deletions src-docs/runner_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a href="../src/reactive/runner_manager.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

# <kbd>module</kbd> `runner_manager`
Runner Manager manages the runners on LXD and GitHub.
Module for managing reactive runners.

**Global Variables**
---------------
Expand All @@ -17,6 +17,31 @@ Runner Manager manages the runners on LXD and GitHub.
- **TIMEOUT_COMMAND**
- **UBUNTU_USER**

---

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

## <kbd>function</kbd> `reconcile`

```python
reconcile(quantity: int, config: ReactiveRunnerConfig) → int
```

Spawn a runner reactively.



**Args:**

- <b>`quantity`</b>: The number of runners to spawn.
- <b>`config`</b>: The configuration for the reactive runner.



**Raises:**

- <b>`ReactiveRunnerError`</b>: If the runner fails to spawn.


---

Expand All @@ -32,7 +57,7 @@ Manage a group of runners according to configuration.
- <b>`runner_bin_path`</b>: The github runner app scripts path.
- <b>`cron_path`</b>: The path to runner build image cron job.

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

### <kbd>method</kbd> `__init__`

Expand All @@ -59,7 +84,7 @@ Construct RunnerManager object for creating and managing runners.

---

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

### <kbd>method</kbd> `build_runner_image`

Expand All @@ -79,7 +104,7 @@ Build container image in test mode, else virtual machine image.

---

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

### <kbd>method</kbd> `check_runner_bin`

Expand All @@ -96,7 +121,7 @@ Check if runner binary exists.

---

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

### <kbd>method</kbd> `flush`

Expand Down Expand Up @@ -125,7 +150,7 @@ Remove existing runners.

---

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

### <kbd>method</kbd> `get_github_info`

Expand All @@ -142,7 +167,7 @@ Get information on the runners from GitHub.

---

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

### <kbd>method</kbd> `get_latest_runner_bin_url`

Expand Down Expand Up @@ -173,7 +198,7 @@ The runner binary URL changes when a new version is available.

---

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

### <kbd>method</kbd> `has_runner_image`

Expand All @@ -190,7 +215,7 @@ Check if the runner image exists.

---

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

### <kbd>method</kbd> `reconcile`

Expand All @@ -214,7 +239,7 @@ Bring runners in line with target.

---

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

### <kbd>method</kbd> `schedule_build_runner_image`

Expand All @@ -226,7 +251,7 @@ Install cron job for building runner image.

---

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

### <kbd>method</kbd> `update_runner_bin`

Expand All @@ -253,7 +278,7 @@ Remove the existing runner binary to prevent it from being used. This is done to

---

<a href="../src/reactive/runner_manager.py#L22"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/reactive/runner_manager.py#L24"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ReactiveRunnerError`
Raised when a reactive runner error occurs.
Expand All @@ -264,17 +289,17 @@ Raised when a reactive runner error occurs.

---

<a href="../src/reactive/runner_manager.py#L26"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/reactive/runner_manager.py#L28"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ReactiveRunnerManager`
A class to manage the reactive runners.
## <kbd>class</kbd> `ReactiveRunnerConfig`
ReactiveRunnerConfig(mq_uri: str, queue_name: str)

<a href="../src/reactive/runner_manager.py#L29"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../<string>"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(reactive_config: ReactiveConfig, queue_name: str)
__init__(mq_uri: str, queue_name: str)None
```


Expand All @@ -284,28 +309,4 @@ __init__(reactive_config: ReactiveConfig, queue_name: str)



---

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

### <kbd>method</kbd> `reconcile`

```python
reconcile(quantity: int) → int
```

Spawn a runner reactively.



**Args:**

- <b>`queue_name`</b>: The name of the queue.



**Raises:**

- <b>`ReactiveRunnerError`</b>: If the runner fails to spawn.


20 changes: 10 additions & 10 deletions src-docs/runner_manager.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Manage a group of runners according to configuration.
- <b>`runner_bin_path`</b>: The github runner app scripts path.
- <b>`cron_path`</b>: The path to runner build image cron job.

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

### <kbd>function</kbd> `__init__`

Expand All @@ -50,7 +50,7 @@ Construct RunnerManager object for creating and managing runners.

---

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

### <kbd>function</kbd> `build_runner_image`

Expand All @@ -70,7 +70,7 @@ Build container image in test mode, else virtual machine image.

---

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

### <kbd>function</kbd> `check_runner_bin`

Expand All @@ -87,7 +87,7 @@ Check if runner binary exists.

---

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

### <kbd>function</kbd> `flush`

Expand Down Expand Up @@ -116,7 +116,7 @@ Remove existing runners.

---

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

### <kbd>function</kbd> `get_github_info`

Expand All @@ -133,7 +133,7 @@ Get information on the runners from GitHub.

---

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

### <kbd>function</kbd> `get_latest_runner_bin_url`

Expand Down Expand Up @@ -164,7 +164,7 @@ The runner binary URL changes when a new version is available.

---

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

### <kbd>function</kbd> `has_runner_image`

Expand All @@ -181,7 +181,7 @@ Check if the runner image exists.

---

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

### <kbd>function</kbd> `reconcile`

Expand All @@ -205,7 +205,7 @@ Bring runners in line with target.

---

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

### <kbd>function</kbd> `schedule_build_runner_image`

Expand All @@ -217,7 +217,7 @@ Install cron job for building runner image.

---

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

### <kbd>function</kbd> `update_runner_bin`

Expand Down
8 changes: 4 additions & 4 deletions src/openstack_cloud/openstack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from openstack.exceptions import OpenStackCloudException, SDKException
from paramiko.ssh_exception import NoValidConnectionsError

import reactive.runner_manager as reactive_runner_manager
from charm_state import (
Arch,
CharmState,
Expand Down Expand Up @@ -69,7 +70,6 @@
from metrics import runner as runner_metrics
from metrics import storage as metrics_storage
from metrics.runner import RUNNER_INSTALLED_TS_FILE_NAME
from reactive.runner_manager import ReactiveRunnerManager
from repo_policy_compliance_client import RepoPolicyComplianceClient
from runner_manager import IssuedMetricEventsStats
from runner_manager_type import OpenstackRunnerManagerConfig
Expand Down Expand Up @@ -587,10 +587,10 @@ def _reconcile_reactive(self, quantity: int) -> int:
quantity: Number of intended runners.
"""
logger.info("Reactive mode is experimental and not yet fully implemented.")
reactive_runner_manager = ReactiveRunnerManager(
reactive_config=self._config.reactive_config, queue_name=self.app_name
config = reactive_runner_manager.ReactiveRunnerConfig(
mq_uri=self._config.reactive_config.mq_uri, queue_name=self.app_name
)
return reactive_runner_manager.reconcile(quantity=quantity)
return reactive_runner_manager.reconcile(quantity=quantity, config=config)

def _reconcile_runners(self, quantity: int) -> int:
"""Reconcile the number of runners.
Expand Down
Loading

0 comments on commit 22d5561

Please sign in to comment.