Skip to content

Commit ee7313c

Browse files
committed
Move explanation of TrinoStatus to its own section in routing-rules page
1 parent 376758c commit ee7313c

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

docs/routing-rules.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ condition: 'request.getHeader("X-Trino-Client-Tags") contains "label=foo"'
134134

135135
If no rules match, then request is routed to adhoc.
136136

137+
### TrinoStatus
138+
139+
This class attempts to track the current state of Trino cluster. It is updated per every healthcheck.
140+
There are three possible states
141+
142+
* PENDING
143+
* A Trino cluster will show this state when it is still starting up. It will be treated as
144+
unhealthy by RoutingManager, and therefore requests will not be routed to PENDING clusters
145+
* HEALTHY
146+
* A Trino cluster will show this state when healthchecks report clusters as healthy and ready.
147+
RoutingManager will only route requests to healthy clusters
148+
* UNHEALTHY
149+
* A Trino cluster will show this state when healthchecks report clusters as unhealthy. RoutingManager
150+
will not route requests to unhealthy clusters.
151+
137152
### TrinoRequestUser
138153

139154
This class attempts to extract the user from a request. In order, it attempts

gateway-ha/src/main/java/io/trino/gateway/ha/clustermonitor/TrinoStatus.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
*/
1414
package io.trino.gateway.ha.clustermonitor;
1515

16-
/**
17-
* PENDING is for ui/observability purpose and functionally it's unhealthy
18-
* We should use PENDING when Trino clusters are still spinning up
19-
* HEALTHY is when health checks report clusters as up
20-
* UNHEALTHY is when health checks report clusters as down
21-
*/
2216
public enum TrinoStatus
2317
{
2418
PENDING,

gateway-ha/src/test/java/io/trino/gateway/ha/HaGatewayTestUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ public static void setUpBackend(
146146
.build();
147147
Response response = httpClient.newCall(request).execute();
148148
assertThat(response.isSuccessful()).isTrue();
149-
TrinoStatus newClusterHealthState = TrinoStatus.PENDING;
149+
TrinoStatus newTrinoStatus = TrinoStatus.PENDING;
150150
Stopwatch stopwatch = Stopwatch.createStarted();
151151
// pull cluster health states for 10 seconds
152152
// It should be enough as the healthcheck is run every second
153153
Duration timeout = Duration.ofSeconds(10);
154-
while (newClusterHealthState != TrinoStatus.HEALTHY && stopwatch.elapsed().compareTo(timeout) < 0) {
154+
while (newTrinoStatus != TrinoStatus.HEALTHY && stopwatch.elapsed().compareTo(timeout) < 0) {
155155
// check the state of newly added cluster every second
156156
Request getBackendStateRequest = new Request.Builder()
157157
.url(format("http://localhost:%s/api/public/backends/%s/state", routerPort, name))
@@ -163,14 +163,14 @@ public static void setUpBackend(
163163
ResponseBody getBackendStateResponseBody = getBackendStateResponse.body();
164164
if (getBackendStateResponseBody != null) {
165165
ClusterStats clusterStats = responseCodec.fromJson(getBackendStateResponseBody.string());
166-
newClusterHealthState = clusterStats.healthState();
167-
log.debug("health state for cluster %s is %s", name, newClusterHealthState);
166+
newTrinoStatus = clusterStats.healthStatus();
167+
log.debug("health state for cluster %s is %s", name, newTrinoStatus);
168168
}
169169
}
170170
}
171171
Thread.sleep(1000);
172172
}
173-
assertThat(newClusterHealthState).isEqualTo(TrinoStatus.HEALTHY);
173+
assertThat(newTrinoStatus).isEqualTo(TrinoStatus.HEALTHY);
174174
}
175175

176176
public record TestConfig(String configFilePath, String h2DbFilePath)

0 commit comments

Comments
 (0)