-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added timeout
to SSHConnector
#644
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #644 +/- ##
==========================================
- Coverage 71.44% 71.41% -0.04%
==========================================
Files 88 88
Lines 11345 11349 +4
Branches 1981 1982 +1
==========================================
- Hits 8106 8105 -1
- Misses 2785 2788 +3
- Partials 454 456 +2 ☔ View full report in Codecov by Sentry. |
6333375
to
2ba9820
Compare
2ba9820
to
e661d94
Compare
raise | ||
if isinstance(err, asyncio.TimeoutError): | ||
raise asyncio.TimeoutError( | ||
f"The SSH connection attempt to {self.get_hostname()} took too long." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"The SSH connection attempt to {self.get_hostname()} took too long." | |
f"SSH connection to {self.get_hostname()} failed: connection timed out" |
@@ -70,6 +70,11 @@ | |||
"description": "Perform a strict validation of the host SSH keys (and return exception if key is not recognized as valid)", | |||
"default": true | |||
}, | |||
"connectTimeout": { | |||
"type": "integer", | |||
"description": "Time (in seconds) to wait for establish the connection. When an attempt fails, the time to wait is increased.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Time (in seconds) to wait for establish the connection. When an attempt fails, the time to wait is increased.", | |
"description": "Max time (in seconds) to wait for establishing an SSH connection.", |
@@ -83,6 +83,7 @@ async def _get_connection( | |||
port=port, | |||
tunnel=await self._get_connection(config.tunnel), | |||
username=config.username, | |||
connect_timeout=config.connect_timeout * (self.connection_attempts + 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the timeout can be left constant.
connect_timeout=( | ||
node["connect_timeout"] | ||
if "connect_timeout" in node | ||
else self.connect_timeout | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect_timeout=( | |
node["connect_timeout"] | |
if "connect_timeout" in node | |
else self.connect_timeout | |
), | |
connect_timeout=node.get("connect_timeout", self.connect_timeout), |
7cfc30f
to
b276530
Compare
…er chooses the time to wait using the `connectTimeout` option. If the `retry` is enabled, the time to wait is increased at each attempt. Updated documentation checksum because the `connectTimeout` option was added in the `SSHConnector` schema
b276530
to
c47e722
Compare
@@ -83,6 +83,7 @@ async def _get_connection( | |||
port=port, | |||
tunnel=await self._get_connection(config.tunnel), | |||
username=config.username, | |||
connect_timeout=config.connect_timeout * self.connection_attempts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connect_timeout=config.connect_timeout * self.connection_attempts, | |
connect_timeout=config.connect_timeout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the timeout can be left constant.
19062e9
to
6a46771
Compare
6a46771
to
22aa629
Compare
This commit adds the timeout in the
asyncssh.connect()
call. The user chooses the time to wait using theconnectTimeout
option.Updated documentation checksum because the
connectTimeout
option was added in theSSHConnector
schema