Skip to content

Commit

Permalink
server: implement health endpoint for app tenants
Browse files Browse the repository at this point in the history
Previously, there was a separate implementation of the Health endpoint for
tenants in `tenant_admin.go`. Now that we've unified the implementations, that
needs to be added to `adminServer`. The implementation for the system tenant
uses liveness, this implementation uses the sqlServer's readiness to accept
connections.

Epic: CRDB-17356

Release note: None
  • Loading branch information
dhartunian committed Dec 13, 2022
1 parent 3ef084c commit 834c8e5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/server/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,33 @@ func (s *adminServer) Cluster(
}, nil
}

// Health returns whether this sql tenant is ready to receive
// traffic.
//
// See the docstring for HealthRequest for more details about
// what this function precisely reports.
//
// Note: Health is non-privileged and non-authenticated and thus
// must not report privileged information.
func (s *adminServer) Health(
ctx context.Context, req *serverpb.HealthRequest,
) (*serverpb.HealthResponse, error) {
telemetry.Inc(telemetryHealthCheck)

resp := &serverpb.HealthResponse{}
// If Ready is not set, the client doesn't want to know whether this node is
// ready to receive client traffic.
if !req.Ready {
return resp, nil
}

if !s.sqlServer.isReady.Get() {
return nil, grpcstatus.Errorf(codes.Unavailable, "node is not accepting SQL clients")
}

return resp, nil
}

// Health returns liveness for the node target of the request.
//
// See the docstring for HealthRequest for more details about
Expand Down

0 comments on commit 834c8e5

Please sign in to comment.