Skip to content

Commit

Permalink
Dev: utils: Catch PermissionError when reading files (#1543)
Browse files Browse the repository at this point in the history
Log a warning message instead of an error during the crm report process
under hacluster, as logging an error may be considered too severe
  • Loading branch information
liangxin1300 authored Sep 9, 2024
2 parents 1d497d0 + a7480fa commit 28abc7c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3102,6 +3102,9 @@ def read_from_file(infile: str) -> str:
try:
with _open(infile, 'rt', encoding='utf-8', errors='replace') as f:
data = f.read()
except PermissionError as err:
logger.warning("When reading file \"%s\": %s", infile, str(err))
return ""
except Exception as err:
logger.error("When reading file \"%s\": %s", infile, str(err))
return ""
Expand Down

0 comments on commit 28abc7c

Please sign in to comment.