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

Do not store failed connections in host attributes #497

Merged
merged 4 commits into from
Mar 24, 2020

Conversation

dmfigol
Copy link
Collaborator

@dmfigol dmfigol commented Mar 22, 2020

With this fix failed connections are not stored in host.connections dictionary, which means we are not trying to close them, raising an exception.
Besides fixing bug #350, this also now allows to have a transparent retry mechanism for tasks which work with connections. Previously, any retry on the host, connection to which has failed, would leave a connection attribute uninitialized and ultimately fail.

@dmfigol dmfigol changed the title Do not store failed connections in host attributes | Fix #350 Do not store failed connections in host attributes Mar 22, 2020

self.connections.pop(connection).close()
connection = self.connections.pop(conn_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should actually trip mypy. You are storing a type of some sort in a variable that was previously defined as a str so maybe it's better to skip the conn_name and rename this to conn = self.connections.pop(conn_name)

@dbarrosop
Copy link
Contributor

Excellent work, just a couple of minor comments but I am pre-approving it as they are very minor

@dbarrosop
Copy link
Contributor

Awesome, thanks!

@dbarrosop dbarrosop merged commit cbbcf83 into nornir-automation:develop Mar 24, 2020
dbarrosop pushed a commit that referenced this pull request Sep 6, 2020
* Tests for failed connections #350

* Do not store failed connections in host.connections, fix #350

* Replace sentinel object UNESTABLISHED_CONNECTION with None

* Use variable name conn_obj instead of connection not to confuse mypy
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.

2 participants