Skip to content

Commit

Permalink
scrapy: searching backtrace with gzip
Browse files Browse the repository at this point in the history
Scrapy script that trying to find backtrace in gzip log files
can hit TypeError: a bytes-like object is required, not 'str' error
and fail to collect results. the gzip file need to be decoded.

Fixes: https://tracker.ceph.com/issues/64402
Signed-off-by: Nitzan Mordechai <[email protected]>
  • Loading branch information
NitzanMordhai committed Mar 31, 2024
1 parent 69caab8 commit 7fdf4c3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions teuthology/scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import difflib
from errno import ENOENT
from gzip import GzipFile
import gzip
import sys
import os
import yaml
Expand Down Expand Up @@ -356,6 +356,8 @@ def _populate_backtrace(self):
return

for line in grep(tlog_path, "command crashed with signal"):
if not line:
continue
log.debug("Found a crash indication: {0}".format(line))
# tasks.ceph.osd.1.plana82.stderr
match = re.search(r"tasks.ceph.([^\.]+).([^\.]+).([^\.]+).stderr", line)
Expand All @@ -382,7 +384,10 @@ def _populate_backtrace(self):
))
continue

bt, ass = self._search_backtrace(GzipFile(gzipped_log_path))
with gzip.open(gzipped_log_path, 'rb') as f:
# Read and decode the contents into strings
decoded_content = f.read().decode('utf-8')
bt, ass = self._search_backtrace(decoded_content)
if ass and not self.assertion:
self.assertion = ass
if bt:
Expand Down

0 comments on commit 7fdf4c3

Please sign in to comment.