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

add health check to wait for sidecar and test it #918

Merged
merged 35 commits into from
Dec 19, 2023

Conversation

cicoyle
Copy link
Contributor

@cicoyle cicoyle commented Sep 20, 2023

Description

Adding a health check to the wait for sidecar logic such that there is better parity with the dotnet sdk. Updated the README. Updated the pom.xml to fix the err: Caused by: java.lang.ClassNotFoundException: org.junit.jupiter.api.extension.ScriptEvaluationException

Issue reference

#897

Checklist

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

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
@cicoyle cicoyle marked this pull request as ready for review September 20, 2023 15:43
@cicoyle cicoyle requested review from a team as code owners September 20, 2023 15:43
@salaboy
Copy link
Contributor

salaboy commented Sep 22, 2023

This looks good to me, great work @cicoyle !

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
sdk/src/main/java/io/dapr/client/DaprClientHttp.java Outdated Show resolved Hide resolved
sdk/src/main/java/io/dapr/client/DaprClientHttp.java Outdated Show resolved Hide resolved
sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java Outdated Show resolved Hide resolved
@olitomlinson
Copy link

@cicoyle @mukundansundar

If you haven't already, It's worth checking in with @artursouza as this class DaprClientHttp is planned to be deprecated in the next version of the SDK.

If that is still true, these changes also need porting over to DaprClientGrpc - as this issue suggests #898

@mukundansundar
Copy link
Contributor

mukundansundar commented Oct 5, 2023

@cicoyle @mukundansundar

If you haven't already, It's worth checking in with @artursouza as this class DaprClientHttp is planned to be deprecated in the next version of the SDK.

If that is still true, these changes also need porting over to DaprClientGrpc - as this issue suggests #898

Good point @olitomlinson! One issue with the gRPC waitForSidecar function is that it only waits for the channel to be ready, not for Dapr outbound to be ready. Either as done in .NET SDK as linked above or as mentioned in the Python SDK issue, we either need gRPC client to also check the HTTP healthz/outbound endpoint or create a IsOutboundReady gRPC method in dapr Runtime.

@olitomlinson
Copy link

olitomlinson commented Oct 5, 2023

@cicoyle @mukundansundar
If you haven't already, It's worth checking in with @artursouza as this class DaprClientHttp is planned to be deprecated in the next version of the SDK.
If that is still true, these changes also need porting over to DaprClientGrpc - as this issue suggests #898

Good point @olitomlinson! One issue with the gRPC waitForSidecar function is that it only waits for the channel to be ready, not for Dapr outbound to be ready. Either as done in .NET SDK as linked above or as mentioned in the Python SDK issue, we either need gRPC client to also check the HTTP healthz/outbound endpoint or create a IsOutboundReady gRPC method in dapr Runtime.

Not that I have any say in the matter, but I think being consistent with the dotnet SDK and calling healthz/outbound is the pragmatic thing to do right now :)

Signed-off-by: Cassie Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
@cicoyle cicoyle force-pushed the fix-wait-for-sidecar-health-check branch from bafccd2 to 61bc31d Compare November 7, 2023 19:36
@cicoyle cicoyle force-pushed the fix-wait-for-sidecar-health-check branch from 61bc31d to 3bb1916 Compare November 7, 2023 19:43
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
@cicoyle cicoyle force-pushed the fix-wait-for-sidecar-health-check branch from abe0521 to 992aa76 Compare November 7, 2023 21:23
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
@cicoyle
Copy link
Contributor Author

cicoyle commented Nov 7, 2023

Unfortunately, this works locally on my Mac, but not in CI - trying to debug

@artursouza
Copy link
Member

I reproduced this error locally.

The error is because the test is not passing the interceptor to an OkHTTP client. You need this in GrpcChannelFacadeTest:

    okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();

And then, use the custom okHttpClient:

DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);

It might be working locally because you might have a running sidecar and makes the test pass.

@cicoyle cicoyle force-pushed the fix-wait-for-sidecar-health-check branch from 0f18d95 to e98f8d7 Compare November 27, 2023 16:01
@@ -43,6 +64,8 @@ class GrpcChannelFacade implements Closeable {
*/
GrpcChannelFacade(ManagedChannel channel) {
this.channel = channel;
OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
this.daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
Copy link
Member

Choose a reason for hiding this comment

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

This should not be forcing port 3500 since the sidecar can run on any port.

Copy link
Member

Choose a reason for hiding this comment

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

I think I fixed it. This line is not really needed, we just move the responsibility of creating the DaprHTTP instance to the caller.

artursouza and others added 5 commits November 27, 2023 23:18
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

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

Comparison is base (0c7828e) 76.55% compared to head (e9d07e4) 76.23%.

Files Patch % Lines
...rc/main/java/io/dapr/client/GrpcChannelFacade.java 73.68% 5 Missing ⚠️
...k/src/main/java/io/dapr/client/DaprClientHttp.java 93.75% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #918      +/-   ##
============================================
- Coverage     76.55%   76.23%   -0.33%     
+ Complexity     1469     1462       -7     
============================================
  Files           138      138              
  Lines          4475     4489      +14     
  Branches        527      524       -3     
============================================
- Hits           3426     3422       -4     
- Misses          763      784      +21     
+ Partials        286      283       -3     

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

@artursouza artursouza merged commit 49ccb31 into dapr:master Dec 19, 2023
14 of 17 checks passed
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.

None yet

6 participants