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

Use logger.exception() to display exceptions details #592

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
34 changes: 17 additions & 17 deletions control/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def lock_omap(self):
self.logger.warning(
f"The OMAP file is locked, will try again in {self.omap_file_lock_retry_sleep_interval} seconds")
time.sleep(self.omap_file_lock_retry_sleep_interval)
except Exception as ex:
self.logger.error(f"Unable to lock OMAP file, exiting: {ex}")
except Exception:
self.logger.exception(f"Unable to lock OMAP file, exiting")
raise

if not got_lock:
Expand Down Expand Up @@ -303,8 +303,8 @@ def unlock_omap(self):
self.is_locked = False
except rados.ObjectNotFound as ex:
self.logger.warning(f"No such lock, the lock duration might have passed")
except Exception as ex:
self.logger.error(f"Unable to unlock OMAP file: {ex}")
except Exception:
self.logger.exception(f"Unable to unlock OMAP file")
gbregman marked this conversation as resolved.
Show resolved Hide resolved
pass

def locked(self):
Expand Down Expand Up @@ -351,9 +351,9 @@ def __init__(self, config):
self.logger.info(
f"First gateway: created object {self.omap_name}")
except rados.ObjectExists:
self.logger.info(f"{self.omap_name} omap object already exists.")
except Exception as ex:
self.logger.error(f"Unable to create omap: {ex}. Exiting!")
self.logger.info(f"{self.omap_name} OMAP object already exists.")
except Exception:
self.logger.exception(f"Unable to create OMAP, exiting!")
raise

def __exit__(self, exc_type, exc_value, traceback):
Expand Down Expand Up @@ -429,8 +429,8 @@ def _add_key(self, key: str, val: str):
self.ioctx.operate_write_op(write_op, self.omap_name)
self.version = version_update
self.logger.debug(f"omap_key generated: {key}")
except Exception as ex:
self.logger.error(f"Unable to add key to omap: {ex}. Exiting!")
except Exception:
self.logger.exception(f"Unable to add key to OMAP, exiting!")
raise

# Notify other gateways within the group of change
Expand All @@ -453,8 +453,8 @@ def _remove_key(self, key: str):
self.ioctx.operate_write_op(write_op, self.omap_name)
self.version = version_update
self.logger.debug(f"omap_key removed: {key}")
except Exception as ex:
self.logger.error(f"Unable to remove key from omap: {ex}. Exiting!")
except Exception:
self.logger.exception(f"Unable to remove key from OMAP, exiting!")
raise

# Notify other gateways within the group of change
Expand All @@ -473,8 +473,8 @@ def delete_state(self):
(str(1),))
self.ioctx.operate_write_op(write_op, self.omap_name)
self.logger.info(f"Deleted OMAP contents.")
except Exception as ex:
self.logger.error(f"Error deleting OMAP contents: {ex}. Exiting!")
except Exception:
self.logger.exception(f"Error deleting OMAP contents, exiting!")
raise

def register_watch(self, notify_event):
Expand All @@ -486,8 +486,8 @@ def _watcher_callback(notify_id, notifier_id, watch_id, data):
if self.watch is None:
try:
self.watch = self.ioctx.watch(self.omap_name, _watcher_callback)
except Exception as ex:
self.logger.error(f"Unable to initiate watch: {ex}")
except Exception:
self.logger.exception(f"Unable to initiate watch")
gbregman marked this conversation as resolved.
Show resolved Hide resolved
else:
self.logger.info(f"Watch already exists.")

Expand Down Expand Up @@ -587,7 +587,7 @@ def start_update(self):
"""Initiates periodic polling and watch/notify for updates."""
notify_event = threading.Event()
if self.use_notify:
# Register a watch on omap state
# Register a watch on OMAP state
self.omap.register_watch(notify_event)

# Start polling for state updates
Expand All @@ -614,7 +614,7 @@ def compare_state_values(self, val1, val2) -> bool:
return val1_str == val2_str

def update(self) -> bool:
"""Checks for updated omap state and initiates local update."""
"""Checks for updated OMAP state and initiates local update."""

if self.update_is_active_lock.locked():
self.logger.warning(f"An update is already running, ignore")
Expand Down
Loading