You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "flaming-archer (via GitHub)" <gi...@apache.org> on 2026/06/10 09:06:13 UTC
[PR] [MINOR] feat(lance): add health check endpoints for Lance REST servers [gravitino]
flaming-archer opened a new pull request, #11558:
URL: https://github.com/apache/gravitino/pull/11558
### What changes were proposed in this pull request?
This PR adds health check endpoints and a custom authentication filter for the Lance REST server, aligning it with the Iceberg REST server implementation.
1、LanceAuthenticationFilter — A new subclass of AuthenticationFilter that whitelists /lance/health and /lance/health/* paths to bypass authentication, in addition to the default health paths (/health, /api/health). This allows Kubernetes probes and monitoring systems to reach the Lance health endpoints without credentials.
2、LanceHealthOperations — A new JAX-RS resource at /health/live that returns a MicroProfile Health-compatible liveness response (200 OK with UP status).
3、LanceRESTService — Updated to inject LanceAuthenticationFilter into the Jetty server via createAuthenticationFilter() override.
4、build.gradle.kts — Added testImplementation(libs.junit.jupiter.params) dependency for @ParameterizedTest support.
### Why are the changes needed?
- Health check endpoints are required for Kubernetes liveness probes and monitoring integration.
- Without LanceAuthenticationFilter, all Lance REST endpoints (including health checks) require authentication, making health probes fail.
#11553
### Does this PR introduce _any_ user-facing change?
Yes. The Lance REST server now exposes:
- GET /lance/health/live — Liveness probe endpoint (no authentication required).
### How was this patch tested?
Added unit tests:
- TestLanceAuthenticationFilter — Verifies health paths bypass auth and non-health paths require auth.
- TestLanceHealthOperations — Verifies the liveness endpoint returns 200 with UP status.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "flaming-archer (via GitHub)" <gi...@apache.org>.
flaming-archer commented on PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#issuecomment-4668493608
@jerryshao Could you please take a look? You wrote the Iceberg version, so your input would be really helpful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3450451670
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -66,7 +70,13 @@ public void serviceInit(Map<String, String> properties, boolean auxMode) {
LanceConfig lanceConfig = new LanceConfig(properties);
JettyServerConfig serverConfig = JettyServerConfig.fromConfig(lanceConfig);
- server = new JettyServer();
+ server =
+ new JettyServer() {
+ @Override
+ protected javax.servlet.Filter createAuthenticationFilter() {
+ return new LanceAuthenticationFilter();
+ }
+ };
Review Comment:
Should Lance also register root-level health aliases, matching Gravitino and Iceberg REST? Iceberg adds `new HealthAliasServlet("/iceberg")` for `/health/*` and `/health.html`, so common probes can use `/health`, `/health/live`, `/health/ready`, and `/health.html`. This PR only exposes `/lance/health*`; adding `HealthAliasServlet("/lance")` after registering the Lance servlet would make Lance consistent with the existing health endpoint behavior.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -66,7 +70,13 @@ public void serviceInit(Map<String, String> properties, boolean auxMode) {
LanceConfig lanceConfig = new LanceConfig(properties);
JettyServerConfig serverConfig = JettyServerConfig.fromConfig(lanceConfig);
- server = new JettyServer();
+ server =
+ new JettyServer() {
+ @Override
+ protected javax.servlet.Filter createAuthenticationFilter() {
+ return new LanceAuthenticationFilter();
Review Comment:
When adding a Lance-specific auth filter for `/lance/health*`, please also pass the same Lance health matcher to `HttpAuditFilter` below. Iceberg REST uses `IcebergHealthCheckPathMatcher` for both auth and audit filtering. Without the audit-side matcher, `/lance/health/ready` returning 503 will be treated as a normal request failure and emit audit/failure events, because the default matcher only recognizes `/health*` and `/api/health*`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3450449559
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -28,13 +28,17 @@
import org.apache.gravitino.lance.common.config.LanceConfig;
import org.apache.gravitino.lance.common.ops.LanceNamespaceBackend;
import org.apache.gravitino.lance.common.ops.NamespaceWrapper;
+import org.apache.gravitino.lance.service.LanceAuthenticationFilter;
import org.apache.gravitino.listener.EventBus;
import org.apache.gravitino.listener.api.event.EventSource;
import org.apache.gravitino.metrics.MetricsSystem;
import org.apache.gravitino.metrics.source.MetricsSource;
import org.apache.gravitino.server.web.HttpAuditFilter;
import org.apache.gravitino.server.web.HttpServerMetricsSource;
-import org.apache.gravitino.server.web.JettyServer;
+import org.apache.gravitino.server.web.
Review Comment:
This import is currently syntactically broken, so the PR cannot pass formatting/compilation. I verified the PR head with `./gradlew :lance:lance-rest-server:compileJava -PskipITs`, and `:lance:lance-rest-server:spotlessJava` fails with `38:41: error: <identifier> expected`. Please restore the intended import, e.g. `org.apache.gravitino.server.web.JettyServer`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "flaming-archer (via GitHub)" <gi...@apache.org>.
flaming-archer commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3456759850
##########
lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/TestLanceAuthenticationFilter.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.exceptions.UnauthorizedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.lance.namespace.model.ErrorResponse;
+
+public class TestLanceAuthenticationFilter {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ /** Exposes the protected {@code isHealthCheckRequest} method for white-box testing. */
+ private static class TestableFilter extends LanceAuthenticationFilter {
+ boolean isHealth(ServletRequest request) {
+ return isHealthCheckRequest(request);
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "/lance/health",
+ "/lance/health/live",
+ "/lance/health/ready",
+ "/health",
+ "/health/live",
+ "/health/ready",
+ "/health.html",
+ "/api/health",
+ "/api/health/live",
+ "/api/health/ready"
+ })
Review Comment:
Let's align with Iceberg and leave it as is for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3461674921
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceAuthenticationFilter.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.exceptions.UnauthorizedException;
+import org.apache.gravitino.server.authentication.AuthenticationFilter;
+import org.lance.namespace.model.ErrorResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An {@link AuthenticationFilter} subclass for the Lance REST server that:
+ *
+ * <ul>
+ * <li>allows health check endpoints to bypass authentication via {@link
+ * LanceHealthCheckPathMatcher};
+ * <li>returns Lance-compatible JSON error responses on authentication failure instead of the
+ * default HTML error pages.
+ * </ul>
+ */
+public class LanceAuthenticationFilter extends AuthenticationFilter {
Review Comment:
Do we support authenticaton for now for Lance rest?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3461667451
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceHealthOperations.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.dto.HealthCheckDTO;
+import org.apache.gravitino.dto.responses.HealthResponse;
+import org.apache.gravitino.lance.common.ops.NamespaceWrapper;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.server.web.Utils;
+
+/**
+ * Health check endpoints for the Lance REST server. Follows the same MicroProfile Health semantics
+ * as the main Gravitino server.
+ *
+ * <ul>
+ * <li>{@code GET /lance/health/live} — liveness, 200 as long as the HTTP thread can respond
+ * <li>{@code GET /lance/health/ready} — readiness, 200 when the namespace wrapper is initialized
+ * <li>{@code GET /lance/health} — aggregate, 200 when both pass
+ * </ul>
+ *
+ * All endpoints return 503 with a JSON body describing the failed check(s) when unhealthy.
+ */
+@Path("/health")
+@Produces(MediaType.APPLICATION_JSON)
+public class LanceHealthOperations {
+
+ private static final String CHECK_HTTP_SERVER = "httpServer";
+ private static final String CHECK_NAMESPACE_WRAPPER = "namespaceWrapper";
+
+ @Inject private NamespaceWrapper namespaceWrapper;
+
+ /** Default constructor for Jersey auto-discovery. */
+ public LanceHealthOperations() {}
+
+ /**
+ * Liveness probe. Returns 200 as long as the HTTP thread can respond.
+ *
+ * @return 200 OK with an UP {@link HealthResponse}
+ */
+ @GET
+ @Path("/live")
+ @Timed(name = "lance.health.live." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "lance.health.live", absolute = true)
+ public Response live() {
+ HealthCheckDTO check = up(CHECK_HTTP_SERVER, Collections.<String, String>emptyMap());
Review Comment:
**Minor: unnecessary explicit type witness on `Collections.emptyMap()`.**
`Collections.<String, String>emptyMap()` — Java infers the type parameter from context, so the `<String, String>` witness is redundant. `IcebergHealthOperations` uses the inferred form (`Collections.emptyMap()`) throughout. Same applies to the identical calls on lines 105 and 124.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceAuthenticationFilter.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.exceptions.UnauthorizedException;
+import org.apache.gravitino.server.authentication.AuthenticationFilter;
+import org.lance.namespace.model.ErrorResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An {@link AuthenticationFilter} subclass for the Lance REST server that:
+ *
+ * <ul>
+ * <li>allows health check endpoints to bypass authentication via {@link
+ * LanceHealthCheckPathMatcher};
+ * <li>returns Lance-compatible JSON error responses on authentication failure instead of the
+ * default HTML error pages.
+ * </ul>
+ */
+public class LanceAuthenticationFilter extends AuthenticationFilter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LanceAuthenticationFilter.class);
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ public LanceAuthenticationFilter() {
+ healthCheckMatcher = new LanceHealthCheckPathMatcher();
+ }
+
+ @Override
+ protected void sendAuthErrorResponse(HttpServletResponse response, Exception exception)
+ throws IOException {
+ int status;
+ String message;
+ if (exception instanceof UnauthorizedException) {
+ status = HttpServletResponse.SC_UNAUTHORIZED;
+ message = exception.getMessage();
+ if (message == null || message.isEmpty()) {
+ message = "Authentication failed";
+ }
+ } else {
+ status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
Review Comment:
**Bug: `ForbiddenException` maps to 500 instead of 403.**
The `else` branch catches every non-`UnauthorizedException` — including `ForbiddenException` — and returns 500. The base `AuthenticationFilter.sendAuthErrorResponse` has an explicit `ForbiddenException` → 403 branch. This override silently drops that case.
Add an `else if (exception instanceof ForbiddenException)` branch mapping to `SC_FORBIDDEN` (403), and add a corresponding test to `TestLanceAuthenticationFilter`.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceAuthenticationFilter.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.exceptions.UnauthorizedException;
+import org.apache.gravitino.server.authentication.AuthenticationFilter;
+import org.lance.namespace.model.ErrorResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An {@link AuthenticationFilter} subclass for the Lance REST server that:
+ *
+ * <ul>
+ * <li>allows health check endpoints to bypass authentication via {@link
+ * LanceHealthCheckPathMatcher};
+ * <li>returns Lance-compatible JSON error responses on authentication failure instead of the
+ * default HTML error pages.
+ * </ul>
+ */
+public class LanceAuthenticationFilter extends AuthenticationFilter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LanceAuthenticationFilter.class);
+ private static final ObjectMapper MAPPER = new ObjectMapper();
Review Comment:
**Style: Use the project-shared `ObjectMapper` instead of a raw `new ObjectMapper()`.**
The base `AuthenticationFilter` uses `ObjectMapperProvider.objectMapper()`, which carries project-wide serialization config (module registration, null handling, date formats, etc.). `IcebergAuthenticationFilter` similarly uses `IcebergObjectMapper.getInstance()`. A bare `new ObjectMapper()` bypasses all of that — use whichever shared mapper is appropriate for the Lance serialization context.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -66,7 +69,13 @@ public void serviceInit(Map<String, String> properties, boolean auxMode) {
LanceConfig lanceConfig = new LanceConfig(properties);
JettyServerConfig serverConfig = JettyServerConfig.fromConfig(lanceConfig);
Review Comment:
**Minor: consider a named class instead of an anonymous `JettyServer` subclass.**
Anonymous inner classes in field initializers are harder to test and document in isolation. Since `LanceAuthenticationFilter` already exists as a named class, a small named `LanceJettyServer` (even package-private) would be consistent with the rest of the module and easier to reference in tests or javadoc.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -66,7 +69,13 @@ public void serviceInit(Map<String, String> properties, boolean auxMode) {
LanceConfig lanceConfig = new LanceConfig(properties);
JettyServerConfig serverConfig = JettyServerConfig.fromConfig(lanceConfig);
- server = new JettyServer();
+ server =
Review Comment:
**Style: FQN in method signature — use an import instead.**
```java
protected javax.servlet.Filter createAuthenticationFilter() {
```
Per the project coding standards, FQNs inline in code should be replaced with a regular `import javax.servlet.Filter;` declaration. The return type should just be `Filter`.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceHealthCheckPathMatcher.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import org.apache.gravitino.server.web.HealthCheckPathMatcher;
+
+/**
+ * A {@link HealthCheckPathMatcher} for the Lance REST server that additionally recognises {@code
+ * /lance/health} and {@code /lance/health/*} as health check endpoints.
+ *
+ * <p>Pass an instance of this class to both {@link
+ * org.apache.gravitino.server.authentication.AuthenticationFilter} (via {@code
+ * LanceAuthenticationFilter}) and {@link org.apache.gravitino.server.web.HttpAuditFilter} when
+ * constructing the Lance REST server so that both filters agree on which paths are probe traffic.
+ */
+public class LanceHealthCheckPathMatcher extends HealthCheckPathMatcher {
+
+ @Override
+ public boolean isHealthCheckPath(String path) {
+ if (super.isHealthCheckPath(path)) {
+ return true;
+ }
+ if (path == null) {
Review Comment:
**Minor: redundant `null` guard — `super.isHealthCheckPath(path)` already handles `null`.**
`HealthCheckPathMatcher.isHealthCheckPath` returns `false` immediately when `path == null`, so `null` can never reach this second check. The guard is harmless but misleading — it implies `null` could slip through the `super` call. Safe to remove.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceHealthOperations.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service.rest;
+
+import com.codahale.metrics.annotation.ResponseMetered;
+import com.codahale.metrics.annotation.Timed;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.gravitino.dto.HealthCheckDTO;
+import org.apache.gravitino.dto.responses.HealthResponse;
+import org.apache.gravitino.lance.common.ops.NamespaceWrapper;
+import org.apache.gravitino.metrics.MetricNames;
+import org.apache.gravitino.server.web.Utils;
+
+/**
+ * Health check endpoints for the Lance REST server. Follows the same MicroProfile Health semantics
+ * as the main Gravitino server.
+ *
+ * <ul>
+ * <li>{@code GET /lance/health/live} — liveness, 200 as long as the HTTP thread can respond
+ * <li>{@code GET /lance/health/ready} — readiness, 200 when the namespace wrapper is initialized
+ * <li>{@code GET /lance/health} — aggregate, 200 when both pass
+ * </ul>
+ *
+ * All endpoints return 503 with a JSON body describing the failed check(s) when unhealthy.
+ */
+@Path("/health")
+@Produces(MediaType.APPLICATION_JSON)
+public class LanceHealthOperations {
+
+ private static final String CHECK_HTTP_SERVER = "httpServer";
+ private static final String CHECK_NAMESPACE_WRAPPER = "namespaceWrapper";
+
+ @Inject private NamespaceWrapper namespaceWrapper;
+
+ /** Default constructor for Jersey auto-discovery. */
+ public LanceHealthOperations() {}
+
+ /**
+ * Liveness probe. Returns 200 as long as the HTTP thread can respond.
+ *
+ * @return 200 OK with an UP {@link HealthResponse}
+ */
+ @GET
+ @Path("/live")
+ @Timed(name = "lance.health.live." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "lance.health.live", absolute = true)
+ public Response live() {
+ HealthCheckDTO check = up(CHECK_HTTP_SERVER, Collections.<String, String>emptyMap());
+ HealthResponse healthResponse =
+ new HealthResponse(HealthCheckDTO.Status.UP, Collections.singletonList(check));
+ return Utils.ok(healthResponse);
+ }
+
+ /**
+ * Readiness probe. Returns 200 when the {@link NamespaceWrapper} is initialized, 503 otherwise.
+ *
+ * @return 200 OK when ready, 503 Service Unavailable with a DOWN {@link HealthResponse} otherwise
+ */
+ @GET
+ @Path("/ready")
+ @Timed(name = "lance.health.ready." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "lance.health.ready", absolute = true)
+ public Response ready() {
+ HealthCheckDTO namespaceCheck = checkNamespaceWrapper();
+ HealthCheckDTO.Status overall = namespaceCheck.getStatus();
+ HealthResponse body = new HealthResponse(overall, Collections.singletonList(namespaceCheck));
+ return overall == HealthCheckDTO.Status.UP ? Utils.ok(body) : Utils.serviceUnavailable(body);
+ }
+
+ /**
+ * Aggregate health check. Returns 200 when both liveness and readiness pass, 503 otherwise.
+ *
+ * @return 200 OK when healthy, 503 Service Unavailable with failing checks described in the body
+ */
+ @GET
+ @Timed(name = "lance.health." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "lance.health", absolute = true)
+ public Response health() {
+ List<HealthCheckDTO> checks = new ArrayList<>(2);
+ checks.add(up(CHECK_HTTP_SERVER, Collections.<String, String>emptyMap()));
+ checks.add(checkNamespaceWrapper());
+
+ HealthCheckDTO.Status overall =
+ checks.stream().anyMatch(c -> c.getStatus() == HealthCheckDTO.Status.DOWN)
+ ? HealthCheckDTO.Status.DOWN
+ : HealthCheckDTO.Status.UP;
+
+ HealthResponse body = new HealthResponse(overall, checks);
+ return overall == HealthCheckDTO.Status.UP ? Utils.ok(body) : Utils.serviceUnavailable(body);
+ }
+
+ private HealthCheckDTO checkNamespaceWrapper() {
+ NamespaceWrapper wrapper = getNamespaceWrapper();
+ if (wrapper == null) {
+ return down(CHECK_NAMESPACE_WRAPPER, "reason", "namespace wrapper not initialized");
+ }
+ try {
+ wrapper.asNamespaceOps();
Review Comment:
**Functional concern: readiness probe triggers lazy initialization and can block indefinitely.**
```java
wrapper.asNamespaceOps(); // calls initIfNeeded() → synchronized initAll() → initialize()
```
`NamespaceWrapper.asNamespaceOps()` lazily initializes the backend (the comment in that class says "it may block the startup"). A Kubernetes readiness probe hitting `/ready` before initialization completes will block inside the `synchronized` block until `initAll()` finishes (or hangs), which can cause probe timeouts and false pod restarts.
Compare with `IcebergHealthOperations.checkCatalogWrapperManager()` — it simply checks `if (getCatalogWrapperManager() == null)` with no side effects.
`NamespaceWrapper` already has a `private volatile boolean initialized` field. The cleanest fix is to expose a `public boolean isInitialized()` accessor and use that here instead of calling `asNamespaceOps()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3461705166
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -66,7 +69,13 @@ public void serviceInit(Map<String, String> properties, boolean auxMode) {
LanceConfig lanceConfig = new LanceConfig(properties);
JettyServerConfig serverConfig = JettyServerConfig.fromConfig(lanceConfig);
- server = new JettyServer();
+ server =
+ new JettyServer() {
+ @Override
+ protected javax.servlet.Filter createAuthenticationFilter() {
Review Comment:
Don't use the full qualified package name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#issuecomment-4669963305
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|66.92% **`-0.13%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|57.39%|:red_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|46.82%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|3.66%|:red_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|10.4%|:red_circle:|
|catalog-fileset|80.23%|:green_circle:|
|catalog-glue|66.72% **`-19.27%`**|:green_circle:|
|catalog-hive|79.44%|:green_circle:|
|catalog-jdbc-clickhouse|80.02%|:green_circle:|
|catalog-jdbc-common|44.22%|:green_circle:|
|catalog-jdbc-doris|80.28%|:green_circle:|
|catalog-jdbc-hologres|54.03%|:green_circle:|
|catalog-jdbc-mysql|79.23% **`-2.76%`**|:green_circle:|
|catalog-jdbc-oceanbase|78.38%|:green_circle:|
|catalog-jdbc-postgresql|82.29%|:green_circle:|
|catalog-jdbc-starrocks|78.51%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|58.53%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.79%|:green_circle:|
|catalog-lakehouse-paimon|79.15%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.51%|:green_circle:|
|client-java|77.91% **`+0.16%`**|:green_circle:|
|common|49.9%|:green_circle:|
|core|82.38%|:green_circle:|
|filesystem-hadoop3|77.27%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|45.72%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-common|10.39%|:red_circle:|
|hive-metastore-common|53.9%|:green_circle:|
|iceberg-common|57.41%|:green_circle:|
|iceberg-rest-server|73.61%|:green_circle:|
|idp-basic|86.18%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|66.17%|:green_circle:|
|lance-common|20.81%|:red_circle:|
|lance-rest-server|61.71% **`-10.12%`**|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|82.87%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|85.87%|:green_circle:|
|server-common|73.28%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|41.16%|:green_circle:|
|trino-connector|40.13%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|catalog-glue|[GlueCatalogOperations.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogOperations.java)|72.16%|:green_circle:|
||[GlueIcebergTableHelper.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueIcebergTableHelper.java)|38.66%|:red_circle:|
|catalog-jdbc-mysql|[MysqlColumnDefaultValueConverter.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/catalogs/catalog-jdbc-mysql/src/main/java/org/apache/gravitino/catalog/mysql/converter/MysqlColumnDefaultValueConverter.java)|37.14%|:red_circle:|
|client-java|[HTTPClient.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/clients/client-java/src/main/java/org/apache/gravitino/client/HTTPClient.java)|81.21%|:green_circle:|
|lance-rest-server|[LanceHealthOperations.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceHealthOperations.java)|100.0%|:green_circle:|
||[LanceAuthenticationFilter.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceAuthenticationFilter.java)|88.89%|:green_circle:|
||[LanceRESTService.java](https://github.com/flaming-archer/gravitino/blob/3eeb5523718f5c013028e1accc41fce5a8067773/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java)|0.0%|:red_circle:|
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#discussion_r3450490026
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/LanceAuthenticationFilter.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.exceptions.UnauthorizedException;
+import org.apache.gravitino.server.authentication.AuthenticationFilter;
+import org.lance.namespace.model.ErrorResponse;
+
+/**
+ * An {@link AuthenticationFilter} subclass for the Lance REST server that:
+ *
+ * <ul>
+ * <li>allows health check endpoints to bypass authentication;
+ * <li>returns Lance-compatible JSON error responses on authentication failure instead of the
+ * default HTML error pages.
+ * </ul>
+ *
+ * <p>The default {@link AuthenticationFilter} only whitelists /health, /api/health paths. This
+ * subclass additionally permits /lance/health and /lance/health/* so that Kubernetes probes and
+ * monitoring systems can reach the Lance health endpoint without credentials.
+ */
+public class LanceAuthenticationFilter extends AuthenticationFilter {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ @Override
+ protected boolean isHealthCheckRequest(ServletRequest request) {
+ if (super.isHealthCheckRequest(request)) {
+ return true;
+ }
+
+ if (!(request instanceof HttpServletRequest)) {
+ return false;
+ }
+ String path = ((HttpServletRequest) request).getRequestURI();
+ if (path == null) {
+ return false;
+ }
+ return path.equals("/lance/health") || path.startsWith("/lance/health/");
+ }
+
+ @Override
+ protected void sendAuthErrorResponse(HttpServletResponse response, Exception exception)
+ throws IOException {
+ int status =
+ exception instanceof UnauthorizedException
+ ? HttpServletResponse.SC_UNAUTHORIZED
+ : HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ String message = exception.getMessage();
+ if (message == null || message.isEmpty()) {
+ message = "Authentication failed";
+ }
Review Comment:
For non-401 failures, returning `exception.getMessage()` to clients can leak internal details (e.g., stack/implementation information) in 500 responses. Consider returning a generic message for `SC_INTERNAL_SERVER_ERROR` (and logging the exception server-side), while keeping the more specific message for `UnauthorizedException` if desired.
##########
lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/LanceRESTService.java:
##########
@@ -28,13 +28,17 @@
import org.apache.gravitino.lance.common.config.LanceConfig;
import org.apache.gravitino.lance.common.ops.LanceNamespaceBackend;
import org.apache.gravitino.lance.common.ops.NamespaceWrapper;
+import org.apache.gravitino.lance.service.LanceAuthenticationFilter;
import org.apache.gravitino.listener.EventBus;
import org.apache.gravitino.listener.api.event.EventSource;
import org.apache.gravitino.metrics.MetricsSystem;
import org.apache.gravitino.metrics.source.MetricsSource;
import org.apache.gravitino.server.web.HttpAuditFilter;
import org.apache.gravitino.server.web.HttpServerMetricsSource;
-import org.apache.gravitino.server.web.JettyServer;
+import org.apache.gravitino.server.web.
+
+
+ ;
Review Comment:
This import section is syntactically invalid and will fail compilation. Replace it with the intended import (likely `import org.apache.gravitino.server.web.JettyServer;`) and remove the stray blank/semicolon-only lines so the imports are valid Java.
##########
lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/TestLanceAuthenticationFilter.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.lance.service;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.exceptions.UnauthorizedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.lance.namespace.model.ErrorResponse;
+
+public class TestLanceAuthenticationFilter {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ /** Exposes the protected {@code isHealthCheckRequest} method for white-box testing. */
+ private static class TestableFilter extends LanceAuthenticationFilter {
+ boolean isHealth(ServletRequest request) {
+ return isHealthCheckRequest(request);
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(
+ strings = {
+ "/lance/health",
+ "/lance/health/live",
+ "/lance/health/ready",
+ "/health",
+ "/health/live",
+ "/health/ready",
+ "/health.html",
+ "/api/health",
+ "/api/health/live",
+ "/api/health/ready"
+ })
Review Comment:
This test is asserting inherited whitelist behavior from `AuthenticationFilter` (e.g., `/health.html`) in addition to Lance-specific behavior. That makes the Lance test brittle if the base filter’s whitelist changes. Consider limiting this parameter set to the Lance-specific paths (`/lance/health...`) and covering base filter expectations in tests that are scoped to `AuthenticationFilter` (or only assert on behaviors that are part of its documented contract).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#issuecomment-4830879152
@jerryshao
Do you have any further comments on this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "flaming-archer (via GitHub)" <gi...@apache.org>.
flaming-archer commented on PR #11558:
URL: https://github.com/apache/gravitino/pull/11558#issuecomment-4828462152
Hi [@jerryshao](https://github.com/jerryshao), @yuqi1129
Since all checks have passed and [@yuqi1129](https://github.com/yuqi1129) has approved the changes, could you please take another look and merge this PR when you have a moment?
Thank you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11553] feat(lance): add health check endpoints for Lance REST servers [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #11558:
URL: https://github.com/apache/gravitino/pull/11558
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org