Skip to content

Commit

Permalink
config_cache: make autochecks manager public
Browse files Browse the repository at this point in the history
Ultimately we should remove this from the config cache.
The autochecks manager is not related to any of its
functionality.

Change-Id: I9b6b15d24d700b64080f9dfc6ab7d3a0efc7b0f4
  • Loading branch information
mo-ki committed Feb 28, 2025
1 parent 4b5affc commit b91327c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions cmk/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,10 @@ def initialize(self) -> ConfigCache:
self._nodes_cache,
) = _make_clusters_nodes_maps()

self._autochecks_manager = AutochecksManager()
# TODO: remove this from the config cache. It is a completely
# self-contained object that should be passed around (if it really
# has to exist at all).
self.autochecks_manager = AutochecksManager()
self._effective_host_cache: dict[
tuple[HostName, ServiceName, tuple[tuple[str, str], ...], tuple[HostName, ...]],
HostName,
Expand Down Expand Up @@ -2149,7 +2152,7 @@ def check_table(
config_cache=self,
skip_ignored=skip_ignored,
filter_mode=filter_mode,
get_autochecks=self._autochecks_manager.get_autochecks,
get_autochecks=self.autochecks_manager.get_autochecks,
configure_autochecks=self._service_configurer.configure_autochecks,
plugins=plugins,
)
Expand Down Expand Up @@ -3537,7 +3540,7 @@ def get_explicit_service_custom_variables(

def get_discovered_services(self, hostname: HostName) -> Sequence[ConfiguredService]:
return self._service_configurer.configure_autochecks(
hostname, self._autochecks_manager.get_autochecks(hostname)
hostname, self.autochecks_manager.get_autochecks(hostname)
)

def section_name_of(self, section: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tests/testlib/unit/base_configuration_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def apply(self, monkeypatch: MonkeyPatch) -> ConfigCache:
if self._autochecks_mocker.raw_autochecks:
monkeypatch.setattr(
self.config_cache,
"_autochecks_manager",
"autochecks_manager",
self._autochecks_mocker,
raising=False,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cmk/checkengine/test_autochecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_manager_get_autochecks_of(
ts.add_host(HostName("host"))
config_cache = ts.apply(monkeypatch)

manager = config_cache._autochecks_manager
manager = config_cache.autochecks_manager

result = manager.get_autochecks(HostName("host"))
assert result == expected_result
Expand Down

0 comments on commit b91327c

Please sign in to comment.