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

feat: add grpc health, deprecate old health #861

Closed
wants to merge 6 commits into from
Closed

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Aug 24, 2023

  • adds a standard gRPC health check
  • moves HTTP health checks off the metrics port, to the app port (we previously hadn't documented the health-checks are controlled by the metrics port config)
  • deprecates old health checks on metrics port (logs warning)

fixes: #831

closed in favor of: #863

@toddbaert toddbaert requested a review from a team as a code owner August 24, 2023 19:09
@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for polite-licorice-3db33c ready!

Name Link
🔨 Latest commit 465add4
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/64e8da925bbf6a0008ca9aef
😎 Deploy Preview https://deploy-preview-861--polite-licorice-3db33c.netlify.app/concepts/architecture
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -129,16 +130,28 @@ func (s *ConnectService) setupServer(svcConf service.Configuration) (net.Listene

path, handler := schemaConnectV1.NewServiceHandler(fes, append(svcConf.Options, marshalOpts)...)
mux.Handle(path, handler)
mux.Handle(grpchealth.NewHandler(grpchealth.NewStaticChecker(
Copy link
Member Author

@toddbaert toddbaert Aug 24, 2023

Choose a reason for hiding this comment

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

Standard implementation, recommended by buf/conntect.

You can test this locally with grpcurl (below command assumes you've downloaded the health proto to ~/Downloads):

grpcurl -import-path '/home/{your-user}/Downloads/'  -proto health.proto -plaintext localhost:8013 grpc.health.v1.Health/Check


s.serverMtx.Lock()
s.server = &http.Server{
ReadHeaderTimeout: time.Second,
Handler: handler,
Handler: mux,
Copy link
Member Author

@toddbaert toddbaert Aug 24, 2023

Choose a reason for hiding this comment

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

The mux created above was actually unused - instead we just used the one handler originally.

@@ -206,8 +219,10 @@ func (s *ConnectService) startMetricsServer(svcConf service.Configuration) error
s.metricsServer.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
Copy link
Member Author

Choose a reason for hiding this comment

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

In my new implementation, I've used mux instead of this kind of switch statement.

@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Merging #861 (c26e569) into main (5b42486) will decrease coverage by 0.35%.
Report is 3 commits behind head on main.
The diff coverage is 27.77%.

❗ Current head c26e569 differs from pull request most recent head 465add4. Consider uploading reports for the commit 465add4 to get more accurate results

@@            Coverage Diff             @@
##             main     #861      +/-   ##
==========================================
- Coverage   72.67%   72.33%   -0.35%     
==========================================
  Files          27       27              
  Lines        2759     2772      +13     
==========================================
  Hits         2005     2005              
- Misses        667      678      +11     
- Partials       87       89       +2     
Files Changed Coverage Δ
...ore/pkg/service/flag-evaluation/connect_service.go 62.87% <27.77%> (-5.31%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -11,6 +11,7 @@ import (
"time"

schemaConnectV1 "buf.build/gen/go/open-feature/flagd/bufbuild/connect-go/schema/v1/schemav1connect"
"connectrpc.com/grpchealth"
Copy link
Member Author

Choose a reason for hiding this comment

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

this package is a connect-compatible implementation of a gRPC healthcheck.

* adds a standard gRPC health check
* moves HTTP health checks off the metrics port, to the app port
* deprecates old health checks on metrics port

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Copy link
Member

@thisthat thisthat left a comment

Choose a reason for hiding this comment

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

We might consider adding a test using https://github.com/grpc-ecosystem/grpc-health-probe to check the gRPC probes are correct. Currently, the ZD tests use the HTTP probes.

@@ -29,13 +29,13 @@ spec:
readinessProbe:
httpGet:
path: /readyz
port: 8014
Copy link
Member

Choose a reason for hiding this comment

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

please, adapt also the ZD tests manifest to use the new port :)

Copy link
Member Author

@toddbaert toddbaert Aug 25, 2023

Choose a reason for hiding this comment

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

@thisthat flagd-proxy uses the sync package from core, NOT the flag-evaluation package. For this reason, the health-checks of flagd-proxy are not impacted by this change (which may or may not be good, since things will be a bit inconsistent.

Problem is, I'm not 100% sure I can add HTTP 1.1 health-check support to the sync package since it doesn't use connect.

@toddbaert
Copy link
Member Author

We might consider adding a test using https://github.com/grpc-ecosystem/grpc-health-probe to check the gRPC probes are correct. Currently, the ZD tests use the HTTP probes.

We might consider adding a test using https://github.com/grpc-ecosystem/grpc-health-probe to check the gRPC probes are correct. Currently, the ZD tests use the HTTP probes.

great idea!

Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan left a comment

Choose a reason for hiding this comment

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

overal looks good 🙌

approving and hope there will be improvements proposed by this comment - #861 (review)

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert marked this pull request as draft August 25, 2023 17:11
@toddbaert toddbaert closed this Aug 25, 2023
@toddbaert
Copy link
Member Author

Closed in favor of #863

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.

[FEATURE] gRPC Health Check must be implemented in case flagd is accessed via AWS ALB
3 participants