feat: open() waits out sshd's per-source penalty (NetOrk/netork#1800)
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Failing after 15s
driver / types (pull_request) Successful in 1m3s
driver / test (3.13) (pull_request) Failing after 59s
driver / test (3.12) (pull_request) Failing after 1m9s
driver / lowest (pull_request) Failing after 28s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Failing after 2m17s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Failing after 15s
driver / types (pull_request) Successful in 1m3s
driver / test (3.13) (pull_request) Failing after 59s
driver / test (3.12) (pull_request) Failing after 1m9s
driver / lowest (pull_request) Failing after 28s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Failing after 2m17s
driver / publish (pull_request) Skipped
OpenSSH 9.8+ closes every connection from a source it has just penalised, before its banner, for seconds to minutes. open() now wraps netmiko's ConnectHandler in napalm-device-types' retry_refused, so the connection is tried again after 1, 3, 7 and 15 s instead of failing. Needs NAPALM/napalm-device-types#63.
This commit is contained in:
1 parent
7550b884b0
commit
49b7d7fef7
3 files changed
+47
-10
No files matched your search
+15
-10
@@ -67,7 +67,7 @@ from napalm_device_types.models import (
|
||||
UpdateDict,
|
||||
UserDict,
|
||||
)
|
||||
from napalm_device_types.ssh_host_keys import HostKeyCheck
|
||||
from napalm_device_types.ssh_host_keys import HostKeyCheck, retry_refused
|
||||
from netmiko import ConnectHandler
|
||||
from netmiko.exceptions import NetmikoAuthenticationException, NetmikoTimeoutException
|
||||
|
||||
@@ -391,15 +391,20 @@ class LinuxDriver(
|
||||
"""Open the SSH connection and detect the package manager."""
|
||||
try:
|
||||
with self._host_key.netmiko(self.netmiko_optional_args) as netmiko_args_:
|
||||
self._device = ConnectHandler(
|
||||
device_type=self.NETMIKO_DEVICE_TYPE,
|
||||
host=self.hostname,
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
port=self.port,
|
||||
secret=self._secret,
|
||||
timeout=self.timeout,
|
||||
**netmiko_args_,
|
||||
# Again after a pause when sshd closes the connection before its
|
||||
# banner: OpenSSH 9.8+ does that to a source it has just
|
||||
# penalised (NetOrk/netork#1800).
|
||||
self._device = retry_refused(
|
||||
lambda: ConnectHandler(
|
||||
device_type=self.NETMIKO_DEVICE_TYPE,
|
||||
host=self.hostname,
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
port=self.port,
|
||||
secret=self._secret,
|
||||
timeout=self.timeout,
|
||||
**netmiko_args_,
|
||||
)
|
||||
)
|
||||
except NetmikoAuthenticationException as exc:
|
||||
raise ConnectionException(str(exc)) from exc
|
||||
|
||||
Reference in new issue
Block a user