Skip to content

Commit

Permalink
Adapt charm to support COS integration (#127)
Browse files Browse the repository at this point in the history
* Add public interface

* Remove promtail prefix from fcts

* Fix license header

* Merge install and config into start

* Add interface to log metrics

* Add grafana_dashboard lib

* Move logging of event to metrics module

* Introduce charm state

* Update attrs doc

* Implement COS integration

* Remove grafana_dashboard

* Change proxy server settings in test_charm

* Ignore whitelist in pylintrc

* Add missing newlines

* Exclude woke.yaml from license check

* Add final newline to .woke.yaml

* Remove usage of requests.session in metrics

* Pin pydantic more specifically

* Fix type hint/doc string in ProxyConfig

* Pin pydantic

* Rename NotCompleteError

* Remove hardcoding of promtail arch

* Remove hardcoding of promtail arch

* Rename -> download_info

* promtail.start -> promtail.setup

* handle non-happy case first in metrics

* Remove group

* Adapt promtail.yaml.j2

* Introduce constant in test_charm

* Move issue_metrics to RunnerManagerConfig

* Fix promtail.service.j2

* Capture time only when needed

* Narrow the exception catch

* Introduce constants in Promtail

* Retry Promtail health check and raise error

* Use Path.write_bytes in promtail

* set unit status to Blocked for unhealthy promtail

* Fix integration test

Breaking change in latest Pygithub version

* Lint

* Catch RequestException

* Drop Promtail and call Loki directly

* Add unit test for charm state

* Switch to cos_agent integration

* Adapt integration test

* Fix integration test

* Simplify integration test

* Fix issue_event

* Add code to set up logrotate

* Update grafana dashboard

* Cleanup

* Remove status in wait_for_idle

* Small fixes

* Dont keep charm inside state

* Update src-docs

* Dont use mutable default value

* Compute event name on instantiation

* Raise LogrotateSetupError

* Reuse _create_runner func

* Check that metrics log is empty

* Fix docstring in Event

* Lint

* app_no_runner -> app
  • Loading branch information
cbartz authored Oct 10, 2023
1 parent 5511464 commit 2462aca
Show file tree
Hide file tree
Showing 33 changed files with 2,301 additions and 73 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ jobs:
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm_scheduled_events.py
integration-test-charm-metrics:
name: Integration test charm metrics
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
juju: [ 3.1, 2.9 ]
steps:
- uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: ${{ matrix.juju }}/stable
provider: lxd
- name: Enable br_netfilter
run: sudo modprobe br_netfilter
- name: Run Integration tests
run: |
tox -e integration-juju${{ matrix.juju }} -- \
--keep-models \
--path ${{secrets.E2E_TESTING_REPO}} \
--token ${{secrets.E2E_TESTING_TOKEN}} \
--token-alt ${{secrets.E2E_TESTING_TOKEN_ALT}} \
tests/integration/test_charm_metrics.py
required_status_checks:
name: Required Integration Test Status Checks
runs-on: ubuntu-latest
Expand All @@ -108,6 +132,7 @@ jobs:
- integration-test-charm
- integration-test-charm-fork-repo
- integration-test-charm-scheduled-events
- integration-test-charm-metrics
if: always() && !cancelled()
timeout-minutes: 30
steps:
Expand All @@ -116,3 +141,4 @@ jobs:
[ '${{ needs.integration-test-charm.result }}' = 'success' ] || (echo integration-test-charm failed && false)
[ '${{ needs.integration-test-charm-fork-repo.result }}' = 'success' ] || (echo integration-test-charm-fork-repo failed && false)
[ '${{ needs.integration-test-charm-scheduled-events.result }}' = 'success' ] || (echo integration-test-charm-schedule-events failed && false)
[ '${{ needs.integration-test-charm-metrics.result }}' = 'success' ] || (echo integration-test-charm-metrics failed && false)
2 changes: 2 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ header:
- 'CODEOWNERS'
- 'icon.svg'
- 'LICENSE'
- '.pylintrc'
- '.woke.yaml'
comment: on-failure
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MAIN]
extension-pkg-whitelist=pydantic # see https://github.com/pydantic/pydantic/issues/1961#issuecomment-759522422
3 changes: 3 additions & 0 deletions .woke.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignore_files:
# Ignore pylintrc as it uses non compliant terminology: whitelist
- .pylintrc
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ If there are more idle runners than configured, the oldest idle runners are unre

During each time period, every unit will make one or more API calls to GitHub. The interval may need to be adjusted if the number of units is large enough to trigger [Rate Limiting](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).


## COS
The charm is designed to provide comprehensive metrics and monitoring capabilities for both the Runners and the Charm itself. These metrics are made available through the `cos-agent` integration with the `cos_agent` interface. Additionally, a Grafana Dashboard is included to help visualize these metrics effectively.

### Loki Integration
#### Loki Push API
The charm seamlessly integrates with Loki, a powerful log aggregation system, through the `cos_agent` interface. This integration allows the charm to push various metrics and logs related to the Runners and the Charm itself to a Loki instance. This provides valuable insights into the performance and behavior of your deployment.

### Grafana Dashboard
To make monitoring even more accessible, the charm comes with a pre-configured Grafana Dashboard. This dashboard is designed to visualize the metrics collected by the charm, making it easier for operators to track the health and performance of the system.

#### Automated Dashboard Deployment
You can automate the deployment of the Grafana Dashboard using the [cos-integration-k8s](https://charmhub.io/cos-configuration-k8s) charm. This simplifies the setup process and ensures that your monitoring infrastructure is ready to go with minimal manual intervention.

#### Configuration Options
To enable the automated deployment of the Grafana Dashboard, you can provide the following configuration options when deploying the `cos-integration-k8s` charm:

```ini
git_repo=https://https://github.com/canonical/github-runner-operator
git_branch=main
git_depth=1
grafana_dashboards_path=src/grafana_dashboard_metrics
```





## Development

This charm uses black and flake8 for formatting. Both run with the lint stage of tox.
Expand Down
Loading

0 comments on commit 2462aca

Please sign in to comment.