Skip to content

fix: Vault health check - #734

Merged
alexanderankin merged 1 commit into
testcontainers:mainfrom
SergeyTsaplin:fix-vault-health-check
Nov 13, 2024
Merged

fix: Vault health check#734
alexanderankin merged 1 commit into
testcontainers:mainfrom
SergeyTsaplin:fix-vault-health-check

Conversation

@SergeyTsaplin

Copy link
Copy Markdown
Contributor

While migrating from Docker Desktop to Rancher Desktop on macOS, I encountered an issue where container port forwarding to the host machine was taking a long time. This delay caused the health check to fail with the following error:

self=<urllib.request.HTTPHandlerobjectat0x108683a70>http_class=<class'http.client.HTTPConnection'>req=<urllib.request.Requestobjectat0x1087788f0>, http_conn_args= {}
host='localhost:32771', h=<http.client.HTTPConnectionobjectat0x108683fb0>headers= {'Connection': 'close', 'Host': 'localhost:32771', 'User-Agent': 'Python-urllib/3.12'}
defdo_open(self, http_class, req, **http_conn_args):
"""Return an HTTPResponse object for the request, using http_class. http_class must implement the HTTPConnection API from http.client. """host=req.hostifnothost:
raiseURLError('no host given')
# will parse host:porth=http_class(host, timeout=req.timeout, **http_conn_args)
h.set_debuglevel(self._debuglevel)
headers=dict(req.unredirected_hdrs)
headers.update({k: vfork, vinreq.headers.items()
ifknotinheaders})
# TODO: Redesign to handle persistent connections?# Currently, it uses HTTP/1.1 but doesn't support# persistent connections, which can cause blocking.# Ensures the connection closes after the single request.headers["Connection"] ="close"headers= {name.title(): valforname, valinheaders.items()}
ifreq._tunnel_host:
tunnel_headers= {}
proxy_auth_hdr="Proxy-Authorization"ifproxy_auth_hdrinheaders:
tunnel_headers[proxy_auth_hdr] =headers[proxy_auth_hdr]
# Remove Proxy-Authorization from origin server requestdelheaders[proxy_auth_hdr]
h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
try:
h.request(req.get_method(), req.selector, req.data, headers,
encode_chunked=req.has_header('Transfer-encoding'))
exceptOSErroraserr: # Timeout error>raiseURLError(err)
Eurllib.error.URLError: <urlopenerror [Errno61] Connectionrefused>
../../../.asdf/installs/python/3.12.0/lib/python3.12/urllib/request.py:1347: URLError

This pull request resolves the issue.

@codecov

codecovBot commented Nov 13, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@0303d47). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@## main #734 +/- ##
=======================================
Coverage ? 84.82% =======================================
Files ? 12 Lines ? 659 Branches ? 103 =======================================
Hits ? 559 Misses ? 78 Partials ? 22 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexanderankinalexanderankin changed the title Fix Vault health checkFix: Vault health checkNov 13, 2024
@alexanderankinalexanderankin changed the title Fix: Vault health checkfix: Vault health checkNov 13, 2024
@alexanderankin
alexanderankin merged commit 79434d6 into testcontainers:mainNov 13, 2024
alexanderankin pushed a commit that referenced this pull request Dec 10, 2024
🤖 I have created a release *beep* *boop*
---
##
[4.9.0](testcontainers-v4.8.2...testcontainers-v4.9.0)
(2024-11-26)
### Features
* **compose:** support for setting profiles
([#738](#738))
([3e00e71](3e00e71))
* **core:** Support working with env files
([#737](#737))
([932ee30](932ee30))
### Bug Fixes
* allow running all tests
([#721](#721))
([f958cf9](f958cf9))
* **core:** Avoid hanging upon bad docker host connection
([#742](#742))
([4ced198](4ced198))
* **core:** running testcontainer inside container
([#714](#714))
([85a6666](85a6666))
* **generic:** Also catch URLError waiting for ServerContainer
([#743](#743))
([24e354f](24e354f))
* update wait_for_logs to not throw on 'created', and an optimization
([#719](#719))
([271ca9a](271ca9a))
* Vault health check
([#734](#734))
([79434d6](79434d6))
### Documentation
* Documentation fix for ServerContainer
([#671](#671))
([0303d47](0303d47))
---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for freeto 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

@SergeyTsaplin@alexanderankin