diff --git a/content-cache_rock/rockcraft.yaml b/content-cache_rock/rockcraft.yaml index 30d69d8..6f36dc4 100644 --- a/content-cache_rock/rockcraft.yaml +++ b/content-cache_rock/rockcraft.yaml @@ -15,6 +15,8 @@ parts: - nginx-light - bash - coreutils + stage-snaps: + - rocks-nginx-prometheus-exporter/latest/edge copy-config: plugin: dump source: . diff --git a/metadata.yaml b/metadata.yaml index bbc26ef..6b9e6cf 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -35,18 +35,11 @@ source: https://github.com/canonical/content-cache-k8s-operator containers: content-cache: resource: content-cache-image - nginx-prometheus-exporter: - resource: nginx-prometheus-exporter-image resources: content-cache-image: type: oci-image description: Docker image for content-cache to run - nginx-prometheus-exporter-image: - type: oci-image - description: Prometheus exporter for nginx - auto-fetch: true - upstream-source: nginx/nginx-prometheus-exporter:0.11.0 provides: metrics-endpoint: diff --git a/src/charm.py b/src/charm.py index b152b7d..7ed86bf 100755 --- a/src/charm.py +++ b/src/charm.py @@ -20,13 +20,7 @@ IngressRequires, ) from charms.prometheus_k8s.v0.prometheus_scrape import MetricsEndpointProvider -from ops.charm import ( - ActionEvent, - CharmBase, - ConfigChangedEvent, - PebbleReadyEvent, - UpgradeCharmEvent, -) +from ops.charm import ActionEvent, CharmBase, ConfigChangedEvent, UpgradeCharmEvent from ops.main import main from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus, WaitingStatus from tabulate import tabulate @@ -79,10 +73,6 @@ def __init__(self, *args): self.framework.observe( self.on.content_cache_pebble_ready, self._on_content_cache_pebble_ready ) - self.framework.observe( - self.on.nginx_prometheus_exporter_pebble_ready, - self._on_nginx_prometheus_exporter_pebble_ready, - ) # Provide ability for Content-cache to be scraped by Prometheus using prometheus_scrape self._metrics_endpoint = MetricsEndpointProvider( self, jobs=[{"static_configs": [{"targets": ["*:9113"]}]}] @@ -117,17 +107,6 @@ def _on_content_cache_pebble_ready(self, event) -> None: self.model.unit.status = MaintenanceStatus(msg) self.on.config_changed.emit() - def _on_nginx_prometheus_exporter_pebble_ready(self, event: PebbleReadyEvent) -> None: - """Handle content_cache_pebble_ready event and configure workload container. - - Args: - event: Event triggering the pebble ready hook for the nginx prometheus exporter. - """ - msg = "Configuring workload container (nginx-prometheus-exporter-pebble-ready)" - logger.info(msg) - self.model.unit.status = MaintenanceStatus(msg) - self.on.config_changed.emit() - def _on_start(self, event) -> None: """Handle workload container started. @@ -257,23 +236,10 @@ def configure_workload_container(self, event: ConfigChangedEvent) -> None: logger.info(msg) self.unit.status = MaintenanceStatus(msg) container.add_layer(CONTAINER_NAME, pebble_config, combine=True) + container.add_layer(EXPORTER_CONTAINER_NAME, exporter_config, combine=True) container.pebble.replan_services() else: - self.unit.status = WaitingStatus("Waiting for Pebble to start (content-cache)") - event.defer() - return - - exporter_container = self.unit.get_container(EXPORTER_CONTAINER_NAME) - if exporter_container.can_connect(): - msg = "Updating exporter pebble layer config" - logger.info(msg) - self.unit.status = MaintenanceStatus(msg) - exporter_container.add_layer(EXPORTER_CONTAINER_NAME, exporter_config, combine=True) - exporter_container.pebble.replan_services() - else: - self.unit.status = WaitingStatus( - "Waiting for Pebble to start (nginx-prometheus-exporter)" - ) + self.unit.status = WaitingStatus("Waiting for Pebble to start") event.defer() return @@ -298,13 +264,13 @@ def _get_nginx_prometheus_exporter_pebble_config(self): """Generate pebble config for the nginx-prometheus-exporter container. Returns: - Pebble layer config for the nginx-prometheus-exporter container. + Pebble layer config for the nginx-prometheus-exporter layer. """ return { "summary": "Nginx prometheus exporter", "description": "Prometheus exporter for nginx", "services": { - "nginx-exporter": { + "nginx-prometheus-exporter": { "override": "replace", "summary": "Nginx Prometheus Exporter", "command": ( diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 55a2000..5108e22 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -93,12 +93,6 @@ async def get_unit_ip_list_action(): yield get_unit_ip_list_action -@fixture(scope="module") -def nginx_prometheus_exporter_image(metadata): - """Provide the statsd prometheus exporter image from the metadata.""" - yield metadata["resources"]["nginx-prometheus-exporter-image"]["upstream-source"] - - @pytest_asyncio.fixture(scope="function") async def unit_ip_list(get_unit_ip_list): """Yield ip addresses of current units.""" @@ -131,7 +125,6 @@ async def app( app_name: str, charm_file: str, content_cache_image: str, - nginx_prometheus_exporter_image: str, nginx_integrator_app: Application, run_action, ): @@ -162,7 +155,6 @@ async def app( application_name=app_name, resources={ "content-cache-image": content_cache_image, - "nginx-prometheus-exporter-image": nginx_prometheus_exporter_image, }, series="jammy", )