Skip to content

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

Merged
artursouza merged 35 commits into
dapr:masterfrom
cicoyle:fix-wait-for-sidecar-health-check
Dec 19, 2023
Merged

artursouza merged 35 commits into
dapr:masterfrom
cicoyle:fix-wait-for-sidecar-health-check

Conversation

@cicoyle

@cicoyle cicoyle commented Sep 20, 2023 •

Copy link
Copy Markdown
Contributor

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

@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

salaboy commented Sep 22, 2023

Copy link
Copy Markdown
Contributor

This looks good to me, great work @cicoyle !

Comment thread sdk/src/main/java/io/dapr/client/DaprClientHttp.java Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread sdk/src/main/java/io/dapr/client/DaprClientHttp.java Outdated
Comment thread sdk/src/main/java/io/dapr/client/DaprClientHttp.java Outdated
Comment thread sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java Outdated
@olitomlinson

Copy link
Copy Markdown

@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

mukundansundar commented Oct 5, 2023 •

Copy link
Copy Markdown
Contributor

@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

olitomlinson commented Oct 5, 2023 •

Copy link
Copy Markdown

@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 :)

@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
@cicoyle
cicoyle force-pushed the fix-wait-for-sidecar-health-check branch from abe0521 to 992aa76 Compare November 7, 2023 21:23
@cicoyle

cicoyle commented Nov 7, 2023

Copy link
Copy Markdown
Contributor Author

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

@artursouza

Copy link
Copy Markdown
Contributor

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
GrpcChannelFacade(ManagedChannel channel) {
this.channel = channel;
OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
this.daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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.

@codecov

codecov Bot commented Dec 18, 2023

Copy link
Copy Markdown

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.

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.

6 participants