Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix decode errors from searchkit #861

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hotsos/core/host_helpers/apparmor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def profiles(self):

@return: dictionary of {<mode>: {'profiles': <list>, 'count': <int>}}
"""
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
seqdef = SequenceSearchDef(
start=SearchDef(r"(\d+) profiles are in (\S+) mode."),
body=SearchDef(r"\s+(\S+)"),
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/host_helpers/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def stats(self):
if counters:
return counters

s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
seqdef = SequenceSearchDef(
# match start of interface
start=SearchDef(IP_IFACE_NAME_TEMPLATE.format(self.name)),
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/host_helpers/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def memory_current_kb(self):
format(self.name), 'memory.current')
if os.path.exists(cgroupv1):
total_usage = {}
fs = FileSearcher()
fs = FileSearcher(decode_errors='backslashreplace')
fs.add(SearchDef(r'(cache|rss|swap) (\d+)'), path=cgroupv1)
for result in fs.run().get(cgroupv1, {}):
total_usage[result.get(1)] = int(result.get(2))
Expand Down
3 changes: 2 additions & 1 deletion hotsos/core/plugins/kernel/kernlog/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class KernLogBase(object):

def __init__(self):
c = SearchConstraintSearchSince(ts_matcher_cls=CommonTimestampMatcher)
self.searcher = FileSearcher(constraint=c)
self.searcher = FileSearcher(constraint=c,
decode_errors='backslashreplace')
self.hostnet_helper = HostNetworkingHelper()
self.cli_helper = CLIHelper()

Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/kernel/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class Lsof(STOVParserBase):
"""

def _load(self):
search = FileSearcher()
search = FileSearcher(decode_errors='backslashreplace')
with CLIHelperFile() as cli:
fout = cli.lsof_Mnlc()
search.add(SearchDef(self._header_matcher, tag='header'), fout)
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/lxd/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LXD(object):
def instances(self):
""" Return a list of instance names. """
_instances = []
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
seq = SequenceSearchDef(start=SearchDef(r'^## Instances$'),
body=SearchDef(r'^\|\s+(\S+)\s+\|'),
end=SearchDef(r'##.*'),
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/openstack/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def cpu_models(self):

guests = []
seqs = {}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
for i in self.instances.values():
guests.append(i.name)
start = SearchDef(r"\s+<cpu .+>")
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/openvswitch/ovn.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class OVNDBBase(object):

def __init__(self):
contents = mktemp_dump(''.join(self.db_show))
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
s.add(self.resources_sd, contents)
self.results = s.run()

Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/openvswitch/ovs.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def tunnels(self):

nethelp = HostNetworkingHelper()
with CLIHelperFile() as cli:
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'.+ \(([a-z]+): ([a-f\d\.:]+)->([a-f\d\.:]+), .+'
s.add(SearchDef(expr, tag='all'),
cli.ovs_appctl(command='ofproto/list-tunnels'))
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/rabbitmq/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RabbitMQReport(object):
def __init__(self):
# save to file so we can search it later
with CLIHelperFile() as cli:
searcher = FileSearcher()
searcher = FileSearcher(decode_errors='backslashreplace')
fout = cli.rabbitmqctl_report()
searcher.add(self.connections_searchdef, fout)
searcher.add(self.memory_searchdef, fout)
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/sosreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def timed_out_plugins(self):
'sos_logs')):
return timeouts

searcher = FileSearcher()
searcher = FileSearcher(decode_errors='backslashreplace')
path = os.path.join(HotSOSConfig.data_root, 'sos_logs/ui.log')
searcher.add(SearchDef(r".* Plugin (\S+) timed out.*", tag="timeouts"),
path=path)
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/storage/bcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def udev_bcache_devs(self):
""" If bcache devices exist fetch information and return as a list. """
devs = []
with CLIHelperFile() as cli:
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
sdef = SequenceSearchDef(start=SearchDef(r"^P: .+/(bcache\S+)"),
body=SearchDef(r"^S: disk/by-uuid/(\S+)"),
tag="bcacheinfo")
Expand Down
6 changes: 3 additions & 3 deletions hotsos/core/plugins/storage/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def _get_version_info(self, daemon_type=None):
version (and only versions for that daemon type.)
"""
versions = {}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
body = SearchDef(r"\s+\"ceph version (\S+) .+ (\S+) "
r"\(\S+\)\":\s+(\d)+,?$")
if daemon_type is None:
Expand Down Expand Up @@ -800,7 +800,7 @@ def rss(self):

NOTE: this assumes we have ps auxwwwm format.
"""
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
# columns: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
if self.id is not None:
ceph_id = r"--id\s+{}".format(self.id)
Expand Down Expand Up @@ -1030,7 +1030,7 @@ def local_osds(self):
"""
osds = []

s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
sd = SequenceSearchDef(start=SearchDef(r"^=+\s+osd\.(\d+)\s+=+.*"),
body=SearchDef([r"\s+osd\s+(fsid)\s+(\S+)\s*",
r"\s+(devices)\s+([\S]+)\s*"]),
Expand Down
2 changes: 1 addition & 1 deletion hotsos/core/plugins/system/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def ubuntu_pro_status(self):
# human-readable output for now. This function should ideally
# rely on the json output when the upstream sos starts to
# include it.
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
service_status_seqdef = SequenceSearchDef(
start=SearchDef(r"^SERVICE +ENTITLED +STATUS +DESCRIPTION"),
body=SearchDef(r"^(\S+) +(\S+) +(\S+) +(.+)\n"),
Expand Down
3 changes: 2 additions & 1 deletion hotsos/plugin_extensions/juju/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class UnitLogInfo(object):
def error_and_warnings(self):
log.debug("searching unit logs for errors and warnings")
c = SearchConstraintSearchSince(ts_matcher_cls=CommonTimestampMatcher)
searchobj = FileSearcher(constraint=c)
searchobj = FileSearcher(constraint=c,
decode_errors='backslashreplace')
path = os.path.join(HotSOSConfig.data_root, 'var/log/juju/unit-*.log')
ts_expr = r"^([\d-]+)\s+([\d:]+)"
for msg in ['ERROR', 'WARNING']:
Expand Down
3 changes: 2 additions & 1 deletion hotsos/plugin_extensions/openstack/agent/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def __init__(self):
self._agent_results = None
c = SearchConstraintSearchSince(
ts_matcher_cls=CommonTimestampMatcher)
self.searchobj = FileSearcher(constraint=c)
self.searchobj = FileSearcher(constraint=c,
decode_errors='backslashreplace')
# The following are expected to be logged using WARNING log level.
self._agent_warnings = {
'nova': ['MessagingTimeout',
Expand Down
2 changes: 1 addition & 1 deletion hotsos/plugin_extensions/openstack/nova_external_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __call__(self, event):
events_found = {}

c = SearchConstraintSearchSince(ts_matcher_cls=CommonTimestampMatcher)
s = FileSearcher(constraint=c)
s = FileSearcher(constraint=c, decode_errors='backslashreplace')
for result in event.results:
instance_id = result.get(1)
event_id = result.get(2)
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_ordered_complete(self):
expected = {'0': {'duration': 60.0,
'start': start0, 'end': end0},
'1': {'duration': 60.0, 'start': start1, 'end': end1}}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) start'
s.add(SearchDef(expr, tag="eventX-start"), path=fname)
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) end'
Expand All @@ -90,7 +90,7 @@ def test_unordered_complete(self):
expected = {'0': {'duration': 60.0,
'start': start0, 'end': end0},
'1': {'duration': 60.0, 'start': start1, 'end': end1}}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) start'
s.add(SearchDef(expr, tag="eventX-start"), path=fname)
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) end'
Expand All @@ -114,7 +114,7 @@ def test_ordered_complete_clobbered(self):
expected = {'0': {'duration': 60.0,
'start': start0, 'end': end0},
'1': {'duration': 60.0, 'start': start1, 'end': end1}}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) start'
s.add(SearchDef(expr, tag="eventX-start"), path=fname)
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) end'
Expand All @@ -141,7 +141,7 @@ def test_ordered_incomplete_clobbered(self):
expected = {'0': {'duration': 60.0,
'start': start0, 'end': end0},
'1': {'duration': 60.0, 'start': start1, 'end': end1}}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) start'
s.add(SearchDef(expr, tag="eventX-start"), path=fname)
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) end'
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_ordered_incomplete_clobbered2(self):
expected = {'0': {'duration': 120.0,
'start': start0, 'end': end0},
'1': {'duration': 60.0, 'start': start1, 'end': end1}}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) start'
s.add(SearchDef(expr, tag="eventX-start"), path=fname)
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) end'
Expand All @@ -193,7 +193,7 @@ def test_ordered_multiple(self):
expected = {'0': {'duration': 60.0,
'start': start0, 'end': end0},
'1': {'duration': 60.0, 'start': start1, 'end': end1}}
s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) start'
s.add(SearchDef(expr, tag="eventX-start"), path=fname)
expr = r'^([0-9\-]+) (\S+) iteration:([0-9]+) end'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_ycheck_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def _create_search_results(self, path, contents=None):
for line in contents:
fd.write(line)

s = FileSearcher()
s = FileSearcher(decode_errors='backslashreplace')
s.add(SearchDef(r'^(\S+) (\S+) .+', tag='all'), path)
return s.run().find_by_tag('all')

Expand Down
Loading