You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@zeppelin.apache.org by "hyunw9 (via GitHub)" <gi...@apache.org> on 2026/10/18 01:14:23 UTC
Re: [PR] [ZEPPELIN-6576] Add REST API for a bounded on-demand interpreter health check [zeppelin]
hyunw9 commented on code in PR #5419:
URL: https://github.com/apache/zeppelin/pull/5419#discussion_r4305226854
##########
zeppelin-server/src/main/java/org/apache/zeppelin/interpreter/InterpreterHealthChecker.java:
##########
@@ -0,0 +1,201 @@
+/*
+ * 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.zeppelin.interpreter;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import org.apache.zeppelin.interpreter.InterpreterHealthCheck.GroupHealth;
+import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Probes the interpreter processes of one interpreter setting and reports whether they answer,
+ * within a deadline that holds for the whole request.
+ *
+ * <p>Unlike the interpreter status snapshot, which is built from server memory alone, this does
+ * contact the interpreter. That is only acceptable because a probe happens when a user explicitly
+ * asks for one, against a single setting, and under a deadline: {@code isRunning()} costs a socket
+ * connect for docker and a kube-apiserver round trip for k8s, so the same call would be an accident
+ * if a listing made it on a timer.
+ *
+ * <p>The deadline can only be imposed from the outside. {@code isRunning()} takes no timeout
+ * argument, the socket connect behind the docker implementation hardcodes one second, and the
+ * kubernetes client is created with the defaults of its library. So the probe runs on another
+ * thread and this class stops waiting for it, which bounds the response but not the probe:
+ * {@code Future#cancel(boolean)} interrupts, and neither a blocking socket connect nor an HTTP
+ * client call ends on an interrupt. A probe thread can therefore stay busy after its result was
+ * given up on, which is why the pool is small and its threads are daemons.
+ */
+public class InterpreterHealthChecker {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(InterpreterHealthChecker.class);
+
+ /**
+ * Budget for one health check request, shared by all groups of the setting rather than granted to
+ * each of them, so that an isolated setting cannot turn into a per group multiple of it.
+ */
+ @VisibleForTesting
+ static final long PROBE_TIMEOUT_IN_MILLIS = 3_000;
+
+ /**
+ * A probe that was given up on keeps its thread, so this bounds how many can pile up while an
+ * interpreter host is unreachable. Further probes wait for a thread instead of getting one, and
+ * are reported as timed out by the deadline if they never start, which is the honest answer.
+ */
+ private static final int MAX_CONCURRENT_PROBES = 4;
+
+ private final long probeTimeoutInMillis;
+ private final ExecutorService probeExecutor;
+
+ public InterpreterHealthChecker() {
+ this(PROBE_TIMEOUT_IN_MILLIS);
+ }
+
+ @VisibleForTesting
+ InterpreterHealthChecker(long probeTimeoutInMillis) {
+ this.probeTimeoutInMillis = probeTimeoutInMillis;
+ this.probeExecutor = newProbeExecutor();
+ }
+
+ private static ExecutorService newProbeExecutor() {
+ ThreadPoolExecutor executor = new ThreadPoolExecutor(
+ MAX_CONCURRENT_PROBES, MAX_CONCURRENT_PROBES, 60L, TimeUnit.SECONDS,
Review Comment:
Following up on the blocking-call concern raised in #5403: the four-thread limit bounds active probes, but the LinkedBlockingQueue is unbounded.
If all four probes ignore interruption, subsequent checks queue and time out without running. Cancelling their futures does not remove those tasks from this executor's queue.
when i reproduced this with the checker implementation, three subsequent requests left three cancelled tasks queued, and the healthy process was never probed.
Could we bound pending work and remove cancelled queued tasks?
##########
docs/usage/rest_api/interpreter.md:
##########
@@ -520,18 +520,120 @@ The role of registered interpreters, settings and interpreters group are describ
</tr>
</table>
+<br/>
+### Health check an interpreter
Review Comment:
Thanks for documenting the local/YARN limitation in the PR description. The same distinction appears relevant to Kubernetes: isRunning() checks the Pod phase and started, rather than a response from the interpreter.
This means healthy=true / reason=OK can be returned without establishing interpreter reachability, while the API documentation describes the result as whether the interpreter answered.
Could we document the launcher-specific guarantees in the API docs and avoid presenting OK as confirmed reachability?
--
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: reviews-unsubscribe@zeppelin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org