send netconf session_close RPC only if connection is alive #684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connection can be lost from control plane reset or device restart. meta: reset_connection task wll attempt to send a session_close RPC to a dead connection and ncclient will raise an exception preventing the connection socket_path from being closed out.
SUMMARY
Fixes #348
ISSUE TYPE
COMPONENT NAME
netconf connection
ADDITIONAL INFORMATION
meta: reset_connection attempts to close the connection:
https://github.com/ansible/ansible/blob/4cc47307ef2c5f63215f2eb1cffeabdeab1c59d6/lib/ansible/plugins/connection/__init__.py#L379
Which calls the netconf connection close:
ansible.netcommon/plugins/connection/netconf.py
Line 434 in 3185a94
If the conneciton was lost due to restart, ncclient raises exeption preventing the ansible socket from being closed:
https://github.com/ncclient/ncclient/blob/a641253370c632182a94b58aa53b66993b8c9a63/ncclient/transport/session.py#L257
This checks the connection status before attempting to send the RPC call to close the session.