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

fix: Vault health check #734

Merged

Conversation

SergeyTsaplin
Copy link
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.HTTPHandler object at 0x108683a70>
http_class = <class 'http.client.HTTPConnection'>
req = <urllib.request.Request object at 0x1087788f0>, http_conn_args = {}
host = 'localhost:32771', h = <http.client.HTTPConnection object at 0x108683fb0>
headers = {'Connection': 'close', 'Host': 'localhost:32771', 'User-Agent': 'Python-urllib/3.12'}
 
    def do_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.host
        if not host:
            raise URLError('no host given')
        # will parse host:port
        h = http_class(host, timeout=req.timeout, **http_conn_args)
        h.set_debuglevel(self._debuglevel)
        headers = dict(req.unredirected_hdrs)
        headers.update({k: v for k, v in req.headers.items()
                        if k not in headers})
        # 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(): val for name, val in headers.items()}
        if req._tunnel_host:
            tunnel_headers = {}
            proxy_auth_hdr = "Proxy-Authorization"
            if proxy_auth_hdr in headers:
                tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
                # Remove Proxy-Authorization from origin server request
                del headers[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'))
        except OSError as err:  # Timeout error
>           raise URLError(err)
E           urllib.error.URLError: <urlopen error [Errno 61] Connection refused>
 
../../../.asdf/installs/python/3.12.0/lib/python3.12/urllib/request.py:1347: URLError

This pull request resolves the issue.

Copy link

codecov bot commented Nov 13, 2024

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.

@alexanderankin alexanderankin changed the title Fix Vault health check Fix: Vault health check Nov 13, 2024
@alexanderankin alexanderankin changed the title Fix: Vault health check fix: Vault health check Nov 13, 2024
@alexanderankin alexanderankin merged commit 79434d6 into testcontainers:main Nov 13, 2024
15 of 17 checks passed
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 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