Skip to content

Commit

Permalink
fix: change checks and configuration (#79)
Browse files Browse the repository at this point in the history
* fix: restart if check fails, decrease threshold and severity, change configuration

* fix: remove default value

* fix unit test
  • Loading branch information
amandahla authored Nov 8, 2024
1 parent 25a2e8a commit 9bcb85c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ options:
type: string
description: |
The GitHub API Access Token used to collect the Action Billing metrics.
default: "default"
github_org:
type: string
description: |
GitHub Organization from which the Action Billing metrics will be
collected.
default: "default"
1 change: 1 addition & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def _pebble_layer(self) -> ops.pebble.LayerDict:
"services": {
"github-actions-exporter": {
"override": "replace",
"on-check-failure": {gh_exporter.CHECK_READY_NAME: "restart"},
"summary": "github-actions-exporter",
"startup": "enabled",
"user": GITHUB_USER,
Expand Down
3 changes: 2 additions & 1 deletion src/github_actions_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def check_ready() -> Dict:
check.override = "replace"
check.level = "ready"
check.tcp = {"port": GITHUB_METRICS_PORT}
check.threshold = 2
# _CheckDict cannot be imported
return check.to_dict() # type: ignore

Expand Down Expand Up @@ -56,7 +57,7 @@ def is_configuration_valid(state: CharmState) -> bool:
Returns:
True if they are all set
"""
return all([state.github_webhook_token, state.github_api_token, state.github_org])
return state.github_webhook_token or all([state.github_api_token, state.github_org])


def version(container: Container) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/prometheus_alert_rules/github_missing.rule
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ alert: GitHubActionsDashboardTargetMissing
expr: up == 0
for: 0m
labels:
severity: critical
severity: warning
annotations:
summary: Prometheus target missing (instance {{ $labels.instance }})
description: "GitHub Actions Dashboard target has disappeared. An exporter might be crashed.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
2 changes: 0 additions & 2 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def test_default_config(self, mock_container_exec):
updated_plan = self.harness.get_container_pebble_plan("github-actions-exporter").to_dict()
updated_plan_env = updated_plan["services"]["github-actions-exporter"]["environment"]
self.assertEqual("default", updated_plan_env["GITHUB_WEBHOOK_TOKEN"])
self.assertEqual("default", updated_plan_env["GITHUB_API_TOKEN"])
self.assertEqual("default", updated_plan_env["GITHUB_ORG"])

@patch.object(ops.Container, "exec")
def test_valid_webhook_token(self, mock_container_exec):
Expand Down

0 comments on commit 9bcb85c

Please sign in to comment.