Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
CORTX-33037: apply support bundle time filter (#111)
Browse files Browse the repository at this point in the history
Signed-off-by: rohit-k-dwivedi <rohit.k.dwivedi@seagate.com>

Co-authored-by: Chetan S Deshmukh <chetan.deshmukh@seagate.com>
  • Loading branch information
rohit-k-dwivedi and cdeshmukh authored Jul 15, 2022
1 parent 1eaf39e commit e34ae2b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rgw/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@

from enum import Enum


# RGW log files to collect in support bundle
RGW_STARTUP_LOG = 'rgw_startup.log'
RGW_SETUP_LOG = 'rgw_setup.log'
RGW_SUPPORT_BUNDLE_LOG = 'rgw_support_bundle.log'
RADOSGW_ADMIN_LOG = 'radosgw-admin.log'
RGW_1_LOG = 'rgw-1.log'
# regex for following date format "1995-09-27"
LOG_DATE_REGEX = '[0-9]{4}-[0-9]{2}-[0-9]{2}'
DATETIME_DATE_REGEX = '%Y-%m-%d'
# regex for following time format "09:60:60"
LOG_TIME_REGEX = '[0-9]{2}:[0-9]{2}:[0-9]{2}'
DATETIME_TIME_REGEX = '%H:%M:%S'

COMPONENT_NAME = 'rgw'
COMPONENT_SVC_NAME = 'rgw_s3'
DECRYPTION_KEY = 'cortx'
Expand Down
36 changes: 36 additions & 0 deletions src/rgw/support/rgw_support_bundle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RGWSupportBundle:
Log.info(f"{COMPONENT_NAME} support bundle generation started!!")
coredumps = filters.get('coredumps', False)
stacktrace = filters.get('stacktrace', False)
duration = filters.get('duration',False)
machine_id = Conf.machine_id
cortx_config_store = MappedConf(cluster_conf)
log_base = cortx_config_store.get(LOG_PATH_KEY)
Expand Down Expand Up @@ -78,6 +79,41 @@ class RGWSupportBundle:
outfile = os.path.join(RGWSupportBundle._tmp_src, file)
if os.path.isfile(infile):
shutil.copyfile(infile, outfile)

if duration:
# files in delim_space use timestamp syntax as
# [2022-07-10 05:26:57,579] & 2022-07-10 05:26:34
# files in delim_T use timestamp syntax as
# 2022-07-10T05:28:35.570+0000
from cortx.utils.support_framework.log_filters import FilterLog
from cortx.rgw.const import ( RGW_STARTUP_LOG, RGW_SETUP_LOG,
RGW_SUPPORT_BUNDLE_LOG, RADOSGW_ADMIN_LOG, RGW_1_LOG,
LOG_DATE_REGEX, LOG_TIME_REGEX, DATETIME_DATE_REGEX,
DATETIME_TIME_REGEX)

# log files with timestamp syntax "YYYY-mm-DD H:M:S"
delim_space = [RGW_STARTUP_LOG, RGW_SETUP_LOG, RGW_SUPPORT_BUNDLE_LOG]
# log files with timestamp syntax "YYYY-mm-DDTH:M:S"
delim_T = [RADOSGW_ADMIN_LOG, RGW_1_LOG]
for file in os.listdir(RGWSupportBundle._tmp_src):
if file in delim_space:
delim = ' '
elif file in delim_T:
delim = 'T'
else:
continue
log_timestamp_regex = LOG_DATE_REGEX + delim + LOG_TIME_REGEX
datetime_format = DATETIME_DATE_REGEX + delim + DATETIME_TIME_REGEX
# apply log filter to individual file by passing exact filename
# to file_name_reg_ex
FilterLog.limit_time(
src_dir=RGWSupportBundle._tmp_src,
dest_dir=RGWSupportBundle._tmp_src,
duration=duration,
file_name_reg_ex=file,
log_timestamp_regex=log_timestamp_regex,
datetime_format=datetime_format)

else:
Log.error("RGW log file does not exists hence skipping log file collection.")

Expand Down

0 comments on commit e34ae2b

Please sign in to comment.