Skip to content
Open
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
13 changes: 12 additions & 1 deletion openwisp_controller/connection/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,24 @@ def update_config(self, device_id):
return
if _is_update_in_progress(device_id, current_task_id=self.request.id):
return
device_conn = None
try:
device_conn = DeviceConnection.get_working_connection(device)
except NoWorkingDeviceConnectionError:
return
else:
logger.info(f"Updating {device} (pk: {device_id})")
device_conn.update_config()
try:
device_conn.update_config()
except Exception as e:
logger.error(f"update_config failed for device {device_id}: {e}")
raise
Comment on lines +67 to +69
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Preserve traceback when logging update failures.

Use logger.exception(...) instead of logger.error(...) here so failure diagnostics include stack context before re-raising.

As per coding guidelines, unresolved errors should be logged at error level; logger.exception keeps that level and adds traceback context.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openwisp_controller/connection/tasks.py` around lines 67 - 69, In the except
block that catches exceptions for update_config (the block using "except
Exception as e" in openwisp_controller/connection/tasks.py), replace the
logger.error call with logger.exception so the error is logged at error level
with the full traceback before re-raising; keep the same message text (e.g.,
"update_config failed for device {device_id}: {e}") and retain the existing
"raise" to re-raise the exception.

finally:
if device_conn:
try:
device_conn.close()
except Exception as close_err:
logger.warning(f"Error closing connection: {close_err}")


# task timeout is SSH_COMMAND_TIMEOUT plus a 20% margin
Expand Down
Loading