Skip to content

Commit

Permalink
Automation helper: Clear more caches before each call
Browse files Browse the repository at this point in the history
Previously, the following scenario might have led to wrong results:
* Two subsequent automation calls executed by the same worker.
* Both calls use the ruleset matcher with same ruleset but different hosts.

An example would be the automation call `analyse-service` executed for the same
service of two different hosts.

CMK-21990

Change-Id: I503ad585f05654f8dac17fc7a8eb52e91a34c2d9
  • Loading branch information
jherbel committed Feb 25, 2025
1 parent b9f42e9 commit 829656d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmk/base/automation_helper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ def _reload_automation_config(plugins: AgentBasedPlugins) -> config.LoadedConfig


def _clear_caches_before_each_call() -> None:
config.get_config_cache().ruleset_matcher.clear_caches()
ruleset_matcher = config.get_config_cache().ruleset_matcher
ruleset_matcher.ruleset_optimizer.clear_caches()
ruleset_matcher.ruleset_optimizer.clear_ruleset_caches()
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def test_standard_workflow_involving_automations(site: Site) -> None:
site.activate_changes_and_wait_for_core_reload()


@pytest.mark.xfail
def test_two_subsequent_automations_involving_ruleset_matcher_same_ruleset_different_hosts(
request: pytest.FixtureRequest,
site: Site,
Expand Down

0 comments on commit 829656d

Please sign in to comment.