Skip to content

Commit

Permalink
Group all event searches
Browse files Browse the repository at this point in the history
To avoid searching the same file more than once we now
gather all searches from all events and executed all
searches prior to executing event callbacks so that the
results are shared with all and avoiding any repeated
searches of the same file.

Also removes extraneous regex from some search patterns.

Related-To: #850
  • Loading branch information
dosaboy committed May 8, 2024
1 parent 4b97ef1 commit 44be2b1
Show file tree
Hide file tree
Showing 25 changed files with 504 additions and 229 deletions.
5 changes: 1 addition & 4 deletions hotsos/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ def __init__(self, plugins=None):
all will be run.
"""
self._summary = OutputManager()
if plugins:
self.plugins = plugins
else:
self.plugins = plugintools.PLUGINS.keys()
self.plugins = plugins or plugintools.PLUGINS.keys()

def setup_global_env(self):
""" State saved here persists across all plugin runs. """
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/openvswitch/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ class OpenvSwitchEventHandlerBase(OpenvSwitchChecksBase, EventHandlerBase):
@property
def summary(self):
# mainline all results into summary root
ret = self.load_and_run()
ret = self.run()
if ret:
return sorted_dict(ret)
6 changes: 4 additions & 2 deletions hotsos/core/plugintools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from hotsos.core.issues import IssuesManager
from hotsos.core.log import log
from hotsos.core.ycheck.scenarios import YScenarioChecker
from hotsos.core.ycheck.events import EventsPreloader

PLUGINS = {}
PLUGIN_RUN_ORDER = []
Expand Down Expand Up @@ -392,12 +393,13 @@ def run(self):
part_mgr = PartManager()
failed_parts = []
# The following are executed as part of each plugin run (but not last).
ALWAYS_RUN = {'auto_scenario_check': YScenarioChecker}
ALWAYS_RUN = {'auto_scenario_check': YScenarioChecker,
'events_preload': EventsPreloader}
for name, always_parts in ALWAYS_RUN.items():
# update current env to reflect actual part being run
HotSOSConfig.part_name = name
try:
always_parts().load_and_run()
always_parts().run()
except Exception as exc:
failed_parts.append(name)
log.exception("part '%s' raised exception: %s", name, exc)
Expand Down
10 changes: 0 additions & 10 deletions hotsos/core/ycheck/engine/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ def searcher(self):
@return: FileSearcher object to be used by this handler.
"""

@abc.abstractmethod
def load(self):
"""
Load definitions from yaml in preparation for them to be processed.
"""

@abc.abstractmethod
def run(self):
""" Process operations. """

@abc.abstractmethod
def load_and_run(self):
""" Load and run. """
20 changes: 14 additions & 6 deletions hotsos/core/ycheck/engine/properties/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def is_sequence_search(self):
@property
def simple_search(self):
if (self.is_sequence_search or not self.search_pattern or
bool(self.passthrough_results)):
self.passthrough_results):
return

sdef = self.cache.simple_search
Expand All @@ -323,7 +323,7 @@ def simple_search(self):

@property
def sequence_search(self):
if not self.is_sequence_search or bool(self.passthrough_results):
if not self.is_sequence_search or self.passthrough_results:
return

sdef = self.cache.sequence_search
Expand All @@ -334,7 +334,7 @@ def sequence_search(self):
seq_body = self.body
seq_end = self.end

if (seq_body or (seq_end and not bool(self.passthrough_results))):
if (seq_body or (seq_end and not self.passthrough_results)):
sd_start = SearchDef(seq_start.search_pattern)

sd_end = None
Expand All @@ -355,12 +355,12 @@ def sequence_search(self):

log.warning("invalid sequence definition passthrough=%s "
"start=%s, body=%s, end=%s",
bool(self.passthrough_results), seq_start, seq_body,
self.passthrough_results, seq_start, seq_body,
seq_end)

@property
def sequence_passthrough_search(self):
if not self.is_sequence_search or not bool(self.passthrough_results):
if not self.is_sequence_search or not self.passthrough_results:
return

sdef = self.cache.sequence_passthrough_search
Expand All @@ -370,7 +370,7 @@ def sequence_passthrough_search(self):
seq_start = self.start
seq_end = self.end

if bool(self.passthrough_results) and all([seq_start, seq_end]):
if self.passthrough_results and all([seq_start, seq_end]):
# start and end required for core.analytics.LogEventStats
start_tag = "{}-start".format(self.unique_search_tag)
end_tag = "{}-end".format(self.unique_search_tag)
Expand Down Expand Up @@ -460,3 +460,11 @@ class YPropertySearch(YPropertySearchBase, YPropertyMappedOverrideBase):
_override_keys = ['search']
_override_members = [YPropertySearchOpt, YPropertySearchConstraints,
YPropertySequencePart]

@property
def passthrough_results(self):
""" Override the member to ensure we always return a bool. """
if not isinstance(self.content, dict):
return False

return bool(self.content.get('passthrough-results', False))
Loading

0 comments on commit 44be2b1

Please sign in to comment.