Skip to content

Commit

Permalink
add open port support (#287)
Browse files Browse the repository at this point in the history
* add open port support

* add cosl to tox environments

* remove KubernetesServicePatch from scenario tests
  • Loading branch information
lucabello authored Apr 16, 2024
1 parent db99e83 commit 1adee25
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 367 deletions.
341 changes: 0 additions & 341 deletions lib/charms/observability_libs/v1/kubernetes_service_patch.py

This file was deleted.

14 changes: 2 additions & 12 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

import yaml
from charms.loki_k8s.v1.loki_push_api import LokiPushApiProvider
from charms.observability_libs.v1.kubernetes_service_patch import (
KubernetesServicePatch,
ServicePort,
)
from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointConsumer
from charms.tempo_k8s.v1.charm_tracing import trace_charm
from charms.tempo_k8s.v2.tracing import TracingEndpointRequirer
Expand All @@ -34,7 +30,6 @@
extra_types=(
GrafanaAgentCharm,
LokiPushApiProvider,
KubernetesServicePatch,
MetricsEndpointConsumer,
GrafanaDashboard,
),
Expand All @@ -60,14 +55,9 @@ class GrafanaAgentK8sCharm(GrafanaAgentCharm):
def __init__(self, *args):
super().__init__(*args)
self._container = self.unit.get_container(self._name)
self.unit.open_port(protocol="tcp", port=self._http_listen_port)
self.unit.open_port(protocol="tcp", port=self._grpc_listen_port)

self.service_patch = KubernetesServicePatch(
self,
[
ServicePort(self._http_listen_port, name=f"{self.app.name}-http-listen-port"),
ServicePort(self._grpc_listen_port, name=f"{self.app.name}-grpc-listen-port"),
],
)
self._scrape = MetricsEndpointConsumer(self)
self.framework.observe(
self._scrape.on.targets_changed, # pyright: ignore
Expand Down
5 changes: 1 addition & 4 deletions tests/scenario/test_setup_statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ def patch_all(substrate, mock_cfg_path):
grafana_agent.CONFIG_PATH = mock_cfg_path
with patch("subprocess.run", _subp_run_mock):
yield

else:
with patch("charm.KubernetesServicePatch", lambda x, y: None):
yield
yield


def test_install(charm_type, substrate, vroot):
Expand Down
Loading

0 comments on commit 1adee25

Please sign in to comment.