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

Health check #670

Merged
merged 31 commits into from
Feb 13, 2024
Merged

Health check #670

merged 31 commits into from
Feb 13, 2024

Conversation

elena-kolevska
Copy link
Contributor

@elena-kolevska elena-kolevska commented Feb 7, 2024

Description

This PR adds a health check against Dapr's health endpoint instead of checking if the socket is open.

The check is added on all the clients' init methods (grpc, http, async grpc, actor and invocation).

The timeout can be configured through the DAPR_HEALTH_TIMEOUT environment variable.

The default value for DAPR_HEALTH_TIMEOUT is 60 seconds.

Issue reference

#611

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Release notes

When connecting to a remote sidecar, DAPR_HTTP_ENDPOINT needs to be set, even when only gRPC is used, because the health endpoint is http-only.

elena-kolevska and others added 5 commits February 7, 2024 21:51
…structor (dapr#621)

* Fixes bug of constructor argument being used as http endpoint

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Updates tests

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Updates the docs explaining how http service invocation should be configured

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Update daprdocs/content/en/python-sdk-docs/python-client.md

Signed-off-by: Bernd Verst <github@bernd.dev>

---------

Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Bernd Verst <github@bernd.dev>
Co-authored-by: Bernd Verst <github@bernd.dev>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
# Conflicts:
#	dapr/clients/__init__.py
#	dapr/clients/http/client.py
#	dapr/clients/http/dapr_invocation_http_client.py
#	tests/clients/test_http_service_invocation_client.py
#	tests/clients/test_secure_http_service_invocation_client.py
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (fc0e9d1) 86.37% compared to head (1e7f332) 86.18%.
Report is 4 commits behind head on main.

Files Patch % Lines
dapr/clients/health.py 72.72% 9 Missing ⚠️
dapr/aio/clients/grpc/client.py 92.15% 4 Missing ⚠️
dapr/actor/client/proxy.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #670      +/-   ##
==========================================
- Coverage   86.37%   86.18%   -0.19%     
==========================================
  Files          79       82       +3     
  Lines        4094     4170      +76     
==========================================
+ Hits         3536     3594      +58     
- Misses        558      576      +18     

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

Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>

# Conflicts:
#	dapr/clients/http/client.py
#	tests/clients/test_http_service_invocation_client.py
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
dapr/clients/health.py Outdated Show resolved Hide resolved
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>

# Conflicts:
#	tests/clients/test_dapr_async_grpc_client.py
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
@@ -98,7 +98,7 @@ class ActorProxy:
communication.
"""

_default_proxy_factory = ActorProxyFactory()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to the instance creation because it was getting invoked on import(dependency load), which was triggering the healthcheck before the fake test servers would start.

Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
self._fake_dapr_server = FakeDaprSidecar()
self._fake_dapr_server.start(self.server_port)
@classmethod
def setUpClass(cls):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the server creation in all tests to the setUpClass method. With this, we got a speed improvement of around 300% (from ~6m to ~1.45m).

@elena-kolevska elena-kolevska marked this pull request as ready for review February 13, 2024 02:33
@elena-kolevska elena-kolevska requested review from a team as code owners February 13, 2024 02:34
@elena-kolevska elena-kolevska changed the title WIP: Health decorator Health check Feb 13, 2024
Signed-off-by: Elena Kolevska <elena@kolevska.com>
@berndverst berndverst merged commit f4dc8ce into dapr:main Feb 13, 2024
15 of 16 checks passed
@elena-kolevska elena-kolevska linked an issue Feb 13, 2024 that may be closed by this pull request
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.

Check outbound healthz endpoint on sidecar wait
2 participants