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

[PR #7517/8d886b42 backport][stable-7] Close elastic APM client to release connections #7528

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Nov 15, 2023

This is a backport of PR #7517 as merged into main (8d886b4).

SUMMARY

Close elastic-apm client to not leak urllib3 connections.

Fix #7518 and is related to elastic/apm-agent-python#1912

Review with "hide whitespaces" enabled.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.general.plugins.callback.elastic

ADDITIONAL INFORMATION

Running anything with elastic source can cause a Closing the transport connection timed out., because elastic client is not closed.

A small example can trigger the issue.

from ansible_collections.community.general.plugins.callback.elastic import ElasticSource

source = ElasticSource("")
apm_cli = source.init_apm_client("http://localhost:8200", "service", None, None, None)
# Uncomment line below to fix the warning
# apm_cli.close()
$ python -Wd unclosed.py
sys:1: ResourceWarning: unclosed <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 38722), raddr=('127.0.0.1', 8200)>
ResourceWarning: Enable tracemalloc to get the object allocation traceback
# Uncomment apm_cli.close()
$ python -Wd closed.py

* Close elastic APM client to release connections

* Changelog fragment

(cherry picked from commit 8d886b4)
@ansibullbot
Copy link
Collaborator

cc @v1v
click here for bot help

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug callback callback plugin new_contributor Help guide this first time contributor plugins plugin (any type) labels Nov 15, 2023
@felixfontein felixfontein merged commit 9a6f7c5 into stable-7 Nov 15, 2023
140 checks passed
@felixfontein felixfontein deleted the patchback/backports/stable-7/8d886b42ec7f7ab768aed844ca4b182a1813a398/pr-7517 branch November 15, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug callback callback plugin new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants