trinodb / trino-gateway

https://trinodb.github.io/trino-gateway/
Apache License 2.0
122 stars 47 forks source link

Add PENDING type to healthchecks #360

Open andythsu opened 1 month ago

andythsu commented 1 month ago

Description

Resolves https://github.com/trinodb/trino-gateway/issues/222 part 1

Additional context and related issues

Release notes

(X) This is not user-visible or is docs only, and no release notes are required. ( ) Release notes are required. Please propose a release note for me. ( ) Release notes are required, with the following suggested text:

* 
andythsu commented 3 weeks ago

@willmostly

TestGatewayMultipleBackend uses the TrinoContainer from TestContainers for trino1 and trino2, which does not finish its startup() until SELECT 1 returns. So the health check should succeed. customBackend is a MockWebServer so you will need to add an endpoint to satisfy the healthcheck. I do not believe you should need to set health status manually through injection

Sorry for the confusion.

In TestGatewayMultipleBackend and TestGatewaySingleBackend, the clusters are added by calling the post api

The default healthstate when clusters are first added to the gateway is PENDING (and should be). Because PENDING is functionally treated as unhealthy, the test cases will fail (for example, https://github.com/trinodb/trino-gateway/blob/d45c64f516062841339e9ce93e4675257e6e93e8/gateway-ha/src/test/java/io/trino/gateway/ha/TestGatewayHaSingleBackend.java#L65-L70) since all clusters' states are still in PENDING when the test cases run. Unless we wait until the first round of healthcheck kicks in and changes the states from PENDING to HEALTHY, no clusters are available.