Skip to content

Commit b143c17

Browse files
committed
make_sources: simplify signature
Let's just not call the function on clusters. Change-Id: I9b685de2641469df7826828387e3c6cfa20a32f2
1 parent fb22206 commit b143c17

6 files changed

Lines changed: 59 additions & 60 deletions

File tree

cmk/base/automations/check_mk.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,6 +3230,9 @@ def _execute_agent(
32303230
ip_address_of: ip_lookup.IPLookup,
32313231
) -> tuple[int, str]:
32323232
hosts_config = config_cache.hosts_config
3233+
if host_name in hosts_config.clusters:
3234+
return 0, "" # I think we never even call this for cluster hosts?
3235+
32333236
ip_lookup_config = config_cache.ip_lookup_config()
32343237
ip_family = ip_lookup_config.default_address_family(host_name)
32353238
check_interval = config_cache.check_mk_check_interval(host_name)
@@ -3279,7 +3282,6 @@ def _execute_agent(
32793282
stored_walk_path=cmk.utils.paths.snmpwalks_dir,
32803283
walk_cache_path=walk_cache_path,
32813284
),
3282-
is_cluster=host_name in hosts_config.clusters,
32833285
simulation_mode=config.simulation_mode,
32843286
file_cache_options=file_cache_options,
32853287
file_cache_max_age=MaxAge(
@@ -3754,6 +3756,7 @@ def execute(
37543756
)
37553757
config_cache = loading_result.config_cache
37563758
hosts_config = config.make_hosts_config(loading_result.loaded_config)
3759+
37573760
ip_lookup_config = config_cache.ip_lookup_config()
37583761
ip_stack_config = ip_lookup_config.ip_stack_config(hostname)
37593762
ip_family = ip_lookup_config.default_address_family(hostname)
@@ -3795,6 +3798,9 @@ def execute(
37953798
)
37963799

37973800
if ty == "agent":
3801+
if hostname in hosts_config.clusters:
3802+
return GetAgentOutputResult(success, output, AgentRawData(info))
3803+
37983804
core_password_store_file = cmk.utils.password_store.core_password_store_path()
37993805
for source in sources.make_sources(
38003806
plugins,
@@ -3825,7 +3831,6 @@ def execute(
38253831
stored_walk_path=cmk.utils.paths.snmpwalks_dir,
38263832
walk_cache_path=walk_cache_path,
38273833
),
3828-
is_cluster=hostname in hosts_config.clusters,
38293834
simulation_mode=config.simulation_mode,
38303835
file_cache_options=file_cache_options,
38313836
file_cache_max_age=MaxAge(

cmk/base/checkers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ def __call__(
467467
stored_walk_path=cmk.utils.paths.snmpwalks_dir,
468468
walk_cache_path=walk_cache_path,
469469
),
470-
is_cluster=current_host_name in hosts_config.clusters,
471470
force_snmp_cache_refresh=(
472471
self.force_snmp_cache_refresh if not is_cluster else False
473472
),

cmk/base/dump_host.py

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -217,56 +217,61 @@ def dump_host(
217217
)
218218
used_password_store = cmk.utils.password_store.pending_password_store_path()
219219
passwords = cmk.utils.password_store.load(used_password_store)
220-
agenttypes = [
221-
dump_source(source)
222-
for source in sources.make_sources(
223-
plugins,
224-
hostname,
225-
primary_family,
226-
ipaddress,
227-
ip_stack_config,
228-
fetcher_factory=config_cache.fetcher_factory(
229-
config_cache.make_service_configurer(plugins.check_plugins, service_name_config),
230-
ip_address_of,
231-
service_name_config,
232-
enforced_services_table,
233-
),
234-
snmp_fetcher_config=SNMPFetcherConfig(
235-
scan_config=SNMPScanConfig(
236-
on_error=OnError.RAISE,
237-
missing_sys_description=config_cache.missing_sys_description(hostname),
238-
oid_cache_dir=oid_cache_dir,
239-
),
240-
selected_sections=NO_SELECTION,
241-
backend_override=None,
242-
stored_walk_path=stored_walk_path,
243-
walk_cache_path=walk_cache_path,
244-
),
245-
is_cluster=hostname in hosts_config.clusters,
246-
file_cache_options=FileCacheOptions(),
247-
simulation_mode=simulation_mode,
248-
file_cache_max_age=MaxAge.zero(),
249-
snmp_backend=config_cache.get_snmp_backend(hostname),
250-
file_cache_path=file_cache_path,
251-
tcp_cache_path=tcp_cache_path,
252-
tls_config=tls_config,
253-
computed_datasources=config_cache.computed_datasources(hostname),
254-
datasource_programs=config_cache.datasource_programs(hostname),
255-
tag_list=config_cache.host_tags.tag_list(hostname),
256-
management_ip=ip_address_of_mgmt(hostname, primary_family),
257-
management_protocol=config_cache.management_protocol(hostname),
258-
special_agent_command_lines=config_cache.special_agent_command_lines(
220+
agenttypes = (
221+
[]
222+
if hostname in hosts_config.clusters
223+
else [
224+
dump_source(source)
225+
for source in sources.make_sources(
226+
plugins,
259227
hostname,
260228
primary_family,
261229
ipaddress,
262-
password_store_file=used_password_store,
263-
passwords=passwords,
264-
ip_address_of=ip_address_of,
265-
),
266-
agent_connection_mode=config_cache.agent_connection_mode(hostname),
267-
check_mk_check_interval=config_cache.check_mk_check_interval(hostname),
268-
)
269-
]
230+
ip_stack_config,
231+
fetcher_factory=config_cache.fetcher_factory(
232+
config_cache.make_service_configurer(
233+
plugins.check_plugins, service_name_config
234+
),
235+
ip_address_of,
236+
service_name_config,
237+
enforced_services_table,
238+
),
239+
snmp_fetcher_config=SNMPFetcherConfig(
240+
scan_config=SNMPScanConfig(
241+
on_error=OnError.RAISE,
242+
missing_sys_description=config_cache.missing_sys_description(hostname),
243+
oid_cache_dir=oid_cache_dir,
244+
),
245+
selected_sections=NO_SELECTION,
246+
backend_override=None,
247+
stored_walk_path=stored_walk_path,
248+
walk_cache_path=walk_cache_path,
249+
),
250+
file_cache_options=FileCacheOptions(),
251+
simulation_mode=simulation_mode,
252+
file_cache_max_age=MaxAge.zero(),
253+
snmp_backend=config_cache.get_snmp_backend(hostname),
254+
file_cache_path=file_cache_path,
255+
tcp_cache_path=tcp_cache_path,
256+
tls_config=tls_config,
257+
computed_datasources=config_cache.computed_datasources(hostname),
258+
datasource_programs=config_cache.datasource_programs(hostname),
259+
tag_list=config_cache.host_tags.tag_list(hostname),
260+
management_ip=ip_address_of_mgmt(hostname, primary_family),
261+
management_protocol=config_cache.management_protocol(hostname),
262+
special_agent_command_lines=config_cache.special_agent_command_lines(
263+
hostname,
264+
primary_family,
265+
ipaddress,
266+
password_store_file=used_password_store,
267+
passwords=passwords,
268+
ip_address_of=ip_address_of,
269+
),
270+
agent_connection_mode=config_cache.agent_connection_mode(hostname),
271+
check_mk_check_interval=config_cache.check_mk_check_interval(hostname),
272+
)
273+
]
274+
)
270275

271276
if config_cache.is_ping_host(hostname):
272277
agenttypes.append("PING only")

cmk/base/modes/check_mk.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ def mode_dump_agent(options: Mapping[str, object], hostname: HostName) -> None:
703703
stored_walk_path=stored_walk_path,
704704
walk_cache_path=walk_cache_path,
705705
),
706-
is_cluster=False,
707706
simulation_mode=config.simulation_mode,
708707
file_cache_options=file_cache_options,
709708
file_cache_max_age=MaxAge(

cmk/base/sources/_builder.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def __init__(
5454
*,
5555
simulation_mode: bool,
5656
fetcher_factory: FetcherFactory,
57-
is_cluster: bool,
5857
snmp_fetcher_config: SNMPFetcherConfig,
5958
max_age_agent: MaxAge,
6059
max_age_snmp: MaxAge,
@@ -72,7 +71,6 @@ def __init__(
7271
check_mk_check_interval: float,
7372
) -> None:
7473
super().__init__()
75-
assert not is_cluster
7674

7775
self.plugins: Final = plugins
7876
self.host_name: Final = host_name
@@ -308,7 +306,6 @@ def make_sources(
308306
ip_stack_config: IPStackConfig,
309307
*,
310308
fetcher_factory: FetcherFactory,
311-
is_cluster: bool,
312309
force_snmp_cache_refresh: bool = False,
313310
snmp_fetcher_config: SNMPFetcherConfig,
314311
snmp_backend: SNMPBackendEnum,
@@ -328,10 +325,6 @@ def make_sources(
328325
check_mk_check_interval: float,
329326
) -> Sequence[Source]:
330327
"""Sequence of sources available for `host_config`."""
331-
if is_cluster:
332-
# Cluster hosts do not have any actual data sources
333-
# Instead all data is provided by the nodes
334-
return ()
335328

336329
def max_age_snmp() -> MaxAge:
337330
if simulation_mode:
@@ -359,7 +352,6 @@ def max_age_agent() -> MaxAge:
359352
fetcher_factory=fetcher_factory,
360353
snmp_fetcher_config=snmp_fetcher_config,
361354
snmp_backend=snmp_backend,
362-
is_cluster=is_cluster,
363355
max_age_agent=max_age_agent(),
364356
max_age_snmp=max_age_snmp(),
365357
file_cache_path=file_cache_path,

tests/unit/cmk/base/sources/test_data_sources.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def _make_sources(
7575
stored_walk_path=tmp_path,
7676
walk_cache_path=tmp_path,
7777
),
78-
is_cluster=False,
7978
simulation_mode=True,
8079
file_cache_options=FileCacheOptions(),
8180
file_cache_max_age=MaxAge.zero(),

0 commit comments

Comments
 (0)