avoid connection leaks (#80532) - #80787
Conversation
In case TaskExecutor needs to open a new connection it should attempt to properly dispose existing one if any. fixes: ansible#80532
| except AttributeError: | ||
| pass | ||
| except Exception as e: | ||
| display.debug(u"error closing connection: %s" % to_text(e)) |
There was a problem hiding this comment.
aside from missing tests and a changelog ... this might not be a good approach as other connections are reused (even if not for the current task) in the play and this would require the costly re-initialization of them.
I know the winrm connection does somethings differently but a general reaper at the end of the run might be a better solution, though many connections might accumulate during the run. Another issue is that some setups reuse the connections created by Ansible (mostly ssh) , so it would have to be a toggle or a per connection property.
There was a problem hiding this comment.
Thanks for valuable comment, I made this PR more like hotfix to get some guidance how to fix it properly - I am sorry if it should been discussion in Issue first... It seemed to me that task_executor always closes connection at the end of .run() anyway and wasn't aware that connection can be retained over self._connection.close() call there.
I think general reaper at the end might not be good option either as default WinRM quota is quite low (I think its 30 connections per user) so if playbook has a task with more than 30 loop items it will blew before reaper kicks in...
SUMMARY
In case TaskExecutor needs to open a new connection it should attempt to properly dispose existing one if any.
Fixes #80532
ISSUE TYPE
COMPONENT NAME
core