Skip to content

Commit

Permalink
OpensearchCOS module not needed, using COSAgent directly
Browse files Browse the repository at this point in the history
  • Loading branch information
juditnovak committed Dec 4, 2023
1 parent df083e9 commit 16ee479
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 91 deletions.
1 change: 0 additions & 1 deletion lib/charms/opensearch/v0/constants_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
ClientRelationName = "opensearch-client"
PeerRelationName = "opensearch-peers"
PeerClusterRelationName = "peer-cluster"
COSRelationName = "cos-agent"
COSPort = "9200"


Expand Down
9 changes: 2 additions & 7 deletions lib/charms/opensearch/v0/opensearch_base_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
from datetime import datetime
from typing import Dict, List, Optional, Type

from charms.grafana_agent.v0.cos_agent import COSAgentProvider
from charms.opensearch.v0.constants_charm import (
AdminUserInitProgress,
CertsExpirationError,
ClientRelationName,
ClusterHealthRed,
ClusterHealthUnknown,
COSPort,
COSRelationName,
PeerRelationName,
PluginConfigChangeError,
RequestUnitServiceOps,
Expand Down Expand Up @@ -45,7 +45,6 @@
generate_password,
)
from charms.opensearch.v0.opensearch_config import OpenSearchConfig
from charms.opensearch.v0.opensearch_cos import OpenSearchCOSProvider
from charms.opensearch.v0.opensearch_distro import OpenSearchDistribution
from charms.opensearch.v0.opensearch_exceptions import (
OpenSearchError,
Expand Down Expand Up @@ -137,7 +136,7 @@ def __init__(self, *args, distro: Type[OpenSearchDistribution] = None):
self.status = Status(self)
self.health = OpenSearchHealth(self)
self.ops_lock = OpenSearchOpsLock(self)
self.cos_integration = OpenSearchCOSProvider(
self.cos_integration = COSAgentProvider(
self,
metrics_endpoints=[
{"path": "/_prometheus/metrics", "port": COSPort},
Expand Down Expand Up @@ -175,10 +174,6 @@ def __init__(self, *args, distro: Type[OpenSearchDistribution] = None):
self.framework.observe(
self.on[STORAGE_NAME].storage_detaching, self._on_opensearch_data_storage_detaching
)
self.framework.observe(
self.on[COSRelationName].relation_created,
self.cos_integration._on_cos_agent_relation_created,
)

self.framework.observe(self.on.set_password_action, self._on_set_password_action)
self.framework.observe(self.on.get_password_action, self._on_get_password_action)
Expand Down
56 changes: 0 additions & 56 deletions lib/charms/opensearch/v0/opensearch_cos.py

This file was deleted.

6 changes: 0 additions & 6 deletions lib/charms/opensearch/v0/opensearch_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
OpenSearchPluginInstallError,
OpenSearchPluginMissingDepsError,
OpenSearchPluginRemoveError,
OpenSearchPrometheusExporter,
PluginState,
)

Expand All @@ -47,11 +46,6 @@
"config": "plugin_opensearch_knn",
"relation": None,
},
"prometheus-exporter": {
"class": OpenSearchPrometheusExporter,
"config": None,
"relation": "cos-agent",
},
}


Expand Down
20 changes: 0 additions & 20 deletions lib/charms/opensearch/v0/opensearch_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,3 @@ def disable(self) -> OpenSearchPluginConfig:
def name(self) -> str:
"""Returns the name of the plugin."""
return "opensearch-knn"


class OpenSearchPrometheusExporter(OpenSearchPlugin):
"""Implements the opensearch-knn plugin."""

@property
def name(self) -> str:
"""Returns the name of the plugin."""
return "prometheus-exporter"

def config(self) -> OpenSearchPluginConfig:
"""Returns a plugin config object to be applied for enabling the current plugin."""
return OpenSearchPluginConfig(
config_entries_to_add={
"prometheus.metric_name.prefix": "opensearch_",
"prometheus.indices": False,
"prometheus.cluster.settings": False,
"prometheus.nodes.filter": "_all",
}
)
2 changes: 1 addition & 1 deletion tests/integration/plugins/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.wait_for_idle(
apps=[TLS_CERTIFICATES_APP_NAME, APP_NAME],
status="active",
timeout=3400,
timeout=1400,
idle_period=IDLE_PERIOD,
)
assert len(ops_test.model.applications[APP_NAME].units) == 3
Expand Down

0 comments on commit 16ee479

Please sign in to comment.