Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change checks and configuration #79

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
amandahla marked this conversation as resolved.
Show resolved Hide resolved
"""
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
Loading