Skip to content

[fix] Avoid logging Paramiko exceptions for common SSH/network issues#1002

Closed
arafathsiam99 wants to merge 3 commits into
openwisp:masterfrom
arafathsiam99:master
Closed

[fix] Avoid logging Paramiko exceptions for common SSH/network issues#1002
arafathsiam99 wants to merge 3 commits into
openwisp:masterfrom
arafathsiam99:master

Conversation

@arafathsiam99
Copy link
Copy Markdown

@arafathsiam99 arafathsiam99 commented Apr 7, 2025

Avoid logging full stack traces for common SSH connection failures (socket timeout, connection refused, host unreachable) to reduce log noise. These are now handled gracefully without logger.exception().

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1000.

Description of Changes

  • Introduced better error handling for SSH connection failures in Ssh.exec_command and Ssh.connect methods.
  • Avoid logging full exception traces when the error is known (e.g., socket.timeout, socket.error, or known Paramiko connection errors).
  • Replaced logger.exception() with logger.warning() or logger.info() as appropriate for expected failures.
  • Improved log readability and reduced unnecessary noise from transient or expected network issues.

Screenshot

bug_fix

Avoid logging full stack traces for common SSH connection failures
(socket timeout, connection refused, host unreachable) to reduce
log noise. These are now handled gracefully without logger.exception().
@nemesifier nemesifier changed the title Avoid logging Paramiko exceptions for common SSH/network issues [fix] Avoid logging Paramiko exceptions for common SSH/network issues Apr 11, 2025
@pandafy pandafy closed this May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Paramiko exceptions for SSH network issues shouldn't be logged

3 participants