Skip to content

Commit

Permalink
Merge branch 'main' into upload-charm-docs/migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw authored Nov 17, 2023
2 parents 1794f25 + d5afde0 commit 5f7f138
Show file tree
Hide file tree
Showing 14 changed files with 1,309 additions and 157 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ghapi
jinja2
ops
ops>=2.8
pylxd @ git+https://github.com/canonical/pylxd
requests
typing-extensions
Expand Down
76 changes: 74 additions & 2 deletions src-docs/metrics.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Models and functions for the metric events.

---

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

## <kbd>function</kbd> `issue_event`

Expand All @@ -39,7 +39,7 @@ The metric event is logged to the metrics log.

---

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

## <kbd>function</kbd> `setup_logrotate`

Expand Down Expand Up @@ -89,6 +89,41 @@ Initialize the event.



---

## <kbd>class</kbd> `Reconciliation`
Metric event for when the charm has finished reconciliation.



**Attributes:**

- <b>`flavor`</b>: Describes the characteristics of the runner. The flavor could be for example "small".
- <b>`crashed_runners`</b>: The number of crashed runners.
- <b>`idle_runners`</b>: The number of idle runners.
- <b>`duration`</b>: The duration of the reconciliation in seconds.

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

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

```python
__init__(*args, **kwargs)
```

Initialize the event.



**Args:**

- <b>`*args`</b>: The positional arguments to pass to the base class.
- <b>`**kwargs`</b>: The keyword arguments to pass to the base class. These are used to set the specific fields. E.g. timestamp=12345 will set the timestamp field to 12345.





---

## <kbd>class</kbd> `RunnerInstalled`
Expand Down Expand Up @@ -158,3 +193,40 @@ Initialize the event.



---

## <kbd>class</kbd> `RunnerStop`
Metric event for when a runner is stopped.



**Attributes:**

- <b>`flavor`</b>: Describes the characteristics of the runner. The flavor could be for example "small".
- <b>`workflow`</b>: The workflow name.
- <b>`repo`</b>: The repository name.
- <b>`github_event`</b>: The github event.
- <b>`status`</b>: A string describing the reason for stopping the runner.
- <b>`job_duration`</b>: The duration of the job in seconds.

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

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

```python
__init__(*args, **kwargs)
```

Initialize the event.



**Args:**

- <b>`*args`</b>: The positional arguments to pass to the base class.
- <b>`**kwargs`</b>: The keyword arguments to pass to the base class. These are used to set the specific fields. E.g. timestamp=12345 will set the timestamp field to 12345.





4 changes: 2 additions & 2 deletions src-docs/runner_manager.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Check if runner binary exists.

---

<a href="../src/runner_manager.py#L456"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/runner_manager.py#L527"><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 @@ -141,7 +141,7 @@ The runner binary URL changes when a new version is available.

---

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

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

Expand Down
18 changes: 16 additions & 2 deletions src-docs/runner_metrics.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Classes and function to extract the metrics from a shared filesystem.

---

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

## <kbd>function</kbd> `extract`

```python
extract(flavor: str, ignore_runners: set[str]) → None
extract(flavor: str, ignore_runners: set[str]) → dict[Type[Event], int]
```

Extract and issue metrics from runners.
Expand All @@ -36,6 +36,11 @@ If corrupt data is found, an error is raised immediately, as this may indicate t
- <b>`ignore_runners`</b>: The set of runners to ignore.



**Returns:**
A dictionary containing the number of issued events per event type.


---

## <kbd>class</kbd> `PostJobMetrics`
Expand All @@ -52,6 +57,15 @@ Metrics for the post-job phase of a runner.



---

## <kbd>class</kbd> `PostJobStatus`
The status of the post-job phase of a runner.





---

## <kbd>class</kbd> `PreJobMetrics`
Expand Down
7 changes: 1 addition & 6 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,7 @@ def _update_kernel(self, now: bool = False) -> None:
_, exit_code = execute_command(["ls", "/var/run/reboot-required"], check_exit=False)
if exit_code == 0:
logger.info("Rebooting system...")

# The juju-reboot is inject to PATH by juju.
cmd = ["juju-reboot"]
if now:
cmd += ["--now"]
execute_command(cmd)
self.unit.reboot(now=now)

@catch_charm_errors
def _on_upgrade_charm(self, _event: UpgradeCharmEvent) -> None:
Expand Down
Loading

0 comments on commit 5f7f138

Please sign in to comment.