Copilot commented on code in PR #7846:
URL: https://github.com/apache/kyuubi/pull/7846#discussion_r4475749222


##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379

Review Comment:
   These bare addresses cannot connect because jetcd expects endpoint URLs that 
include a scheme. Use `http://host:port` in the example, or `https://` with 
TLS, and correct the same endpoint-format claim at line 90.



##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379
+kyuubi.ha.namespace=kyuubi          # optional, defaults to "kyuubi"
+kyuubi.ha.etcd.lease.timeout=PT10S  # optional, defaults to PT10S

Review Comment:
   Please move these annotations onto separate comment lines. 
`kyuubi-defaults.conf` is loaded with Java `Properties.load`, which retains 
inline `#` text in the value. Copying this example therefore changes the 
namespace and makes the lease timeout fail duration parsing, preventing the 
etcd discovery client from initializing.



##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379
+kyuubi.ha.namespace=kyuubi          # optional, defaults to "kyuubi"
+kyuubi.ha.etcd.lease.timeout=PT10S  # optional, defaults to PT10S
+```
+
+If your etcd uses TLS, set `kyuubi.ha.etcd.ssl.enabled=true` together with the
+ca/certificate/key paths: `kyuubi.ha.etcd.ssl.ca.path`,
+`kyuubi.ha.etcd.ssl.client.certificate.path`,
+`kyuubi.ha.etcd.ssl.client.key.path`.
+
+Notes:
+
+- There is no embedded etcd equivalent to the embedded ZooKeeper in pseudo
+  mode. etcd must run as a service, either inside the Kubernetes cluster
+  (for example a dedicated StatefulSet) or outside it.
+- `kyuubi.ha.addresses` is a comma-separated list of host:port values.
+- The etcd discovery client has no authentication other than mTLS; secure etcd
+  with TLS or a network boundary.
+- Server registrations and engine registrations both use the same namespace.
+- The JDBC driver does not support etcd service discovery;
+  `serviceDiscoveryMode` only works with a ZooKeeper ensemble. etcd is used
+  between Kyuubi servers and engines, not from the JDBC client.
+
+## High Availability on Kubernetes (with etcd)
+
+A production Kubernetes deployment of Kyuubi has three moving parts: the
+Kyuubi servers, their engines (Spark applications), and the discovery store
+they share. A Kubernetes Service can balance new connections across the
+servers, but it does not make engines discoverable or sessions portable, so a
+discovery store is required for a real HA setup.
+
+1. **Deploy etcd for discovery.** Any etcd cluster reachable from the Kyuubi
+   pods works, for example a dedicated StatefulSet in the same namespace, or an
+   etcd cluster running outside Kubernetes. Kyuubi does *not* use the
+   Kubernetes cluster's own etcd automatically; you must pass the endpoints to
+   Kyuubi with `kyuubi.ha.addresses`.
+2. **Configure every server with the same options.** All server replicas must
+   use the same `kyuubi.ha.client.class` and `kyuubi.ha.namespace`. Engines
+   inherit their discovery configuration from the server that starts them.
+   Mount a shared `kyuubi-defaults.conf` (or inject it into the Helm chart
+   values) so this is identical on every pod.
+3. **Let clients connect through the Service.** Point the JDBC driver at the
+   Kyuubi Service (LoadBalancer or NodePort), for example
+   `jdbc:kyuubi://<service-host>:10009/default`. Session stickiness is tied to
+   the server that accepted the connection; if it disappears, reconnecting
+   lands on another replica.
+4. **Engine discovery across servers.** When an engine finishes bootstrapping
+   it registers itself in etcd. Any server that can reach etcd can discover
+   engines created by other servers; without a working discovery store a
+   server cannot route to engines created elsewhere, and a leaked engine
+   cannot be detected and cleaned up.

Review Comment:
   The cleanup claim is too strong. Spark engines run 
`SessionManager.startTerminatingChecker` themselves and can self-terminate 
after their sessions close or time out and the engine idle timeout elapses; 
that check does not require the discovery store. Please separate cross-server 
discovery from engine cleanup rather than implying that losing discovery 
necessarily leaks an engine.



##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379
+kyuubi.ha.namespace=kyuubi          # optional, defaults to "kyuubi"
+kyuubi.ha.etcd.lease.timeout=PT10S  # optional, defaults to PT10S
+```
+
+If your etcd uses TLS, set `kyuubi.ha.etcd.ssl.enabled=true` together with the
+ca/certificate/key paths: `kyuubi.ha.etcd.ssl.ca.path`,
+`kyuubi.ha.etcd.ssl.client.certificate.path`,
+`kyuubi.ha.etcd.ssl.client.key.path`.
+
+Notes:
+
+- There is no embedded etcd equivalent to the embedded ZooKeeper in pseudo
+  mode. etcd must run as a service, either inside the Kubernetes cluster
+  (for example a dedicated StatefulSet) or outside it.
+- `kyuubi.ha.addresses` is a comma-separated list of host:port values.
+- The etcd discovery client has no authentication other than mTLS; secure etcd
+  with TLS or a network boundary.
+- Server registrations and engine registrations both use the same namespace.
+- The JDBC driver does not support etcd service discovery;
+  `serviceDiscoveryMode` only works with a ZooKeeper ensemble. etcd is used
+  between Kyuubi servers and engines, not from the JDBC client.
+
+## High Availability on Kubernetes (with etcd)
+
+A production Kubernetes deployment of Kyuubi has three moving parts: the
+Kyuubi servers, their engines (Spark applications), and the discovery store
+they share. A Kubernetes Service can balance new connections across the
+servers, but it does not make engines discoverable or sessions portable, so a
+discovery store is required for a real HA setup.
+
+1. **Deploy etcd for discovery.** Any etcd cluster reachable from the Kyuubi
+   pods works, for example a dedicated StatefulSet in the same namespace, or an
+   etcd cluster running outside Kubernetes. Kyuubi does *not* use the
+   Kubernetes cluster's own etcd automatically; you must pass the endpoints to
+   Kyuubi with `kyuubi.ha.addresses`.
+2. **Configure every server with the same options.** All server replicas must
+   use the same `kyuubi.ha.client.class` and `kyuubi.ha.namespace`. Engines
+   inherit their discovery configuration from the server that starts them.
+   Mount a shared `kyuubi-defaults.conf` (or inject it into the Helm chart
+   values) so this is identical on every pod.
+3. **Let clients connect through the Service.** Point the JDBC driver at the
+   Kyuubi Service (LoadBalancer or NodePort), for example
+   `jdbc:kyuubi://<service-host>:10009/default`. Session stickiness is tied to
+   the server that accepted the connection; if it disappears, reconnecting
+   lands on another replica.
+4. **Engine discovery across servers.** When an engine finishes bootstrapping
+   it registers itself in etcd. Any server that can reach etcd can discover
+   engines created by other servers; without a working discovery store a
+   server cannot route to engines created elsewhere, and a leaked engine
+   cannot be detected and cleaned up.
+5. **Batch vs interactive sessions.** Batch session state is shared across
+   Kyuubi instances, so a retried batch operation can be routed to any
+   server. Interactive session state is not shared: if a server disappears

Review Comment:
   etcd does not replicate batch state, and the default metadata store is local 
SQLite, so another replica can return `Invalid batchId`. Document the shared 
JDBC metadata-store prerequisite and require submission retries to reuse the 
same `kyuubi.batch.id` UUID to avoid creating a duplicate batch.



##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379
+kyuubi.ha.namespace=kyuubi          # optional, defaults to "kyuubi"
+kyuubi.ha.etcd.lease.timeout=PT10S  # optional, defaults to PT10S
+```
+
+If your etcd uses TLS, set `kyuubi.ha.etcd.ssl.enabled=true` together with the
+ca/certificate/key paths: `kyuubi.ha.etcd.ssl.ca.path`,
+`kyuubi.ha.etcd.ssl.client.certificate.path`,
+`kyuubi.ha.etcd.ssl.client.key.path`.
+
+Notes:
+
+- There is no embedded etcd equivalent to the embedded ZooKeeper in pseudo
+  mode. etcd must run as a service, either inside the Kubernetes cluster
+  (for example a dedicated StatefulSet) or outside it.
+- `kyuubi.ha.addresses` is a comma-separated list of host:port values.
+- The etcd discovery client has no authentication other than mTLS; secure etcd
+  with TLS or a network boundary.
+- Server registrations and engine registrations both use the same namespace.
+- The JDBC driver does not support etcd service discovery;
+  `serviceDiscoveryMode` only works with a ZooKeeper ensemble. etcd is used
+  between Kyuubi servers and engines, not from the JDBC client.
+
+## High Availability on Kubernetes (with etcd)
+
+A production Kubernetes deployment of Kyuubi has three moving parts: the
+Kyuubi servers, their engines (Spark applications), and the discovery store
+they share. A Kubernetes Service can balance new connections across the
+servers, but it does not make engines discoverable or sessions portable, so a
+discovery store is required for a real HA setup.
+
+1. **Deploy etcd for discovery.** Any etcd cluster reachable from the Kyuubi
+   pods works, for example a dedicated StatefulSet in the same namespace, or an
+   etcd cluster running outside Kubernetes. Kyuubi does *not* use the
+   Kubernetes cluster's own etcd automatically; you must pass the endpoints to
+   Kyuubi with `kyuubi.ha.addresses`.
+2. **Configure every server with the same options.** All server replicas must
+   use the same `kyuubi.ha.client.class` and `kyuubi.ha.namespace`. Engines
+   inherit their discovery configuration from the server that starts them.
+   Mount a shared `kyuubi-defaults.conf` (or inject it into the Helm chart
+   values) so this is identical on every pod.
+3. **Let clients connect through the Service.** Point the JDBC driver at the
+   Kyuubi Service (LoadBalancer or NodePort), for example
+   `jdbc:kyuubi://<service-host>:10009/default`. Session stickiness is tied to
+   the server that accepted the connection; if it disappears, reconnecting
+   lands on another replica.
+4. **Engine discovery across servers.** When an engine finishes bootstrapping
+   it registers itself in etcd. Any server that can reach etcd can discover
+   engines created by other servers; without a working discovery store a
+   server cannot route to engines created elsewhere, and a leaked engine
+   cannot be detected and cleaned up.
+5. **Batch vs interactive sessions.** Batch session state is shared across
+   Kyuubi instances, so a retried batch operation can be routed to any
+   server. Interactive session state is not shared: if a server disappears
+   its interactive sessions are lost, and a reconnecting client must re-run
+   its session-initializing statements (`SET spark.sql.*` and similar) before
+   further queries behave as before.
+6. **etcd failure modes.** A server learns about an engine's unexpected death
+   after up to `kyuubi.ha.etcd.lease.timeout` since the last keep-alive
+   lease. If etcd stops answering, servers fail to register and discover
+   engines, and log discovery errors until etcd is reachable again; clients
+   already connected to a server keep the server they have.

Review Comment:
   The lease timeout governs registration expiry, not when a server detects an 
engine failure. If an outage expires a server or engine registration and its 
watcher observes the deletion, `stopGracefully()` shuts that service down after 
sessions drain, without re-registering it. Describe both behaviors rather than 
promising detection within the timeout and automatic recovery when etcd returns.



##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379
+kyuubi.ha.namespace=kyuubi          # optional, defaults to "kyuubi"
+kyuubi.ha.etcd.lease.timeout=PT10S  # optional, defaults to PT10S
+```
+
+If your etcd uses TLS, set `kyuubi.ha.etcd.ssl.enabled=true` together with the
+ca/certificate/key paths: `kyuubi.ha.etcd.ssl.ca.path`,
+`kyuubi.ha.etcd.ssl.client.certificate.path`,
+`kyuubi.ha.etcd.ssl.client.key.path`.
+
+Notes:
+
+- There is no embedded etcd equivalent to the embedded ZooKeeper in pseudo
+  mode. etcd must run as a service, either inside the Kubernetes cluster
+  (for example a dedicated StatefulSet) or outside it.
+- `kyuubi.ha.addresses` is a comma-separated list of host:port values.
+- The etcd discovery client has no authentication other than mTLS; secure etcd
+  with TLS or a network boundary.
+- Server registrations and engine registrations both use the same namespace.
+- The JDBC driver does not support etcd service discovery;
+  `serviceDiscoveryMode` only works with a ZooKeeper ensemble. etcd is used
+  between Kyuubi servers and engines, not from the JDBC client.
+
+## High Availability on Kubernetes (with etcd)
+
+A production Kubernetes deployment of Kyuubi has three moving parts: the
+Kyuubi servers, their engines (Spark applications), and the discovery store
+they share. A Kubernetes Service can balance new connections across the
+servers, but it does not make engines discoverable or sessions portable, so a
+discovery store is required for a real HA setup.
+
+1. **Deploy etcd for discovery.** Any etcd cluster reachable from the Kyuubi
+   pods works, for example a dedicated StatefulSet in the same namespace, or an
+   etcd cluster running outside Kubernetes. Kyuubi does *not* use the
+   Kubernetes cluster's own etcd automatically; you must pass the endpoints to
+   Kyuubi with `kyuubi.ha.addresses`.
+2. **Configure every server with the same options.** All server replicas must
+   use the same `kyuubi.ha.client.class` and `kyuubi.ha.namespace`. Engines
+   inherit their discovery configuration from the server that starts them.
+   Mount a shared `kyuubi-defaults.conf` (or inject it into the Helm chart
+   values) so this is identical on every pod.
+3. **Let clients connect through the Service.** Point the JDBC driver at the
+   Kyuubi Service (LoadBalancer or NodePort), for example
+   `jdbc:kyuubi://<service-host>:10009/default`. Session stickiness is tied to
+   the server that accepted the connection; if it disappears, reconnecting
+   lands on another replica.
+4. **Engine discovery across servers.** When an engine finishes bootstrapping
+   it registers itself in etcd. Any server that can reach etcd can discover
+   engines created by other servers; without a working discovery store a

Review Comment:
   Reaching etcd alone is not sufficient to discover or reuse every peer's 
engine. The lookup is scoped by `EngineRef.engineSpace`, including share level 
and routing user; for example, `SERVER_LOCAL` engines are per server and 
`CONNECTION` engines are per connection. Please qualify this statement and link 
to the share-level guide.



##########
docs/deployment/high_availability_guide.md:
##########
@@ -64,6 +64,86 @@ But it doesn't have any availability to being highly 
available.
 For production deployment purpose, an external zookeeper cluster is required 
for `kyuubi.ha.addresses`.
 In this mode, multiple `k.i.`s can be registered to the same ServerSpace 
configured by `kyuubi.ha.namespace` and serve together.
 
+### etcd for server and engine discovery
+
+Kyuubi can use [etcd](https://etcd.io/) as the discovery ensemble instead of
+ZooKeeper. Set the following on every Kyuubi server (for example via a shared
+`kyuubi-defaults.conf`):
+
+```text
+kyuubi.ha.client.class=org.apache.kyuubi.ha.client.etcd.EtcdDiscoveryClient
+kyuubi.ha.addresses=etcd1:2379,etcd2:2379,etcd3:2379
+kyuubi.ha.namespace=kyuubi          # optional, defaults to "kyuubi"
+kyuubi.ha.etcd.lease.timeout=PT10S  # optional, defaults to PT10S
+```
+
+If your etcd uses TLS, set `kyuubi.ha.etcd.ssl.enabled=true` together with the
+ca/certificate/key paths: `kyuubi.ha.etcd.ssl.ca.path`,
+`kyuubi.ha.etcd.ssl.client.certificate.path`,
+`kyuubi.ha.etcd.ssl.client.key.path`.
+
+Notes:
+
+- There is no embedded etcd equivalent to the embedded ZooKeeper in pseudo
+  mode. etcd must run as a service, either inside the Kubernetes cluster
+  (for example a dedicated StatefulSet) or outside it.
+- `kyuubi.ha.addresses` is a comma-separated list of host:port values.
+- The etcd discovery client has no authentication other than mTLS; secure etcd
+  with TLS or a network boundary.
+- Server registrations and engine registrations both use the same namespace.
+- The JDBC driver does not support etcd service discovery;
+  `serviceDiscoveryMode` only works with a ZooKeeper ensemble. etcd is used
+  between Kyuubi servers and engines, not from the JDBC client.
+
+## High Availability on Kubernetes (with etcd)
+
+A production Kubernetes deployment of Kyuubi has three moving parts: the
+Kyuubi servers, their engines (Spark applications), and the discovery store
+they share. A Kubernetes Service can balance new connections across the
+servers, but it does not make engines discoverable or sessions portable, so a
+discovery store is required for a real HA setup.
+
+1. **Deploy etcd for discovery.** Any etcd cluster reachable from the Kyuubi
+   pods works, for example a dedicated StatefulSet in the same namespace, or an
+   etcd cluster running outside Kubernetes. Kyuubi does *not* use the

Review Comment:
   Engine driver pods must also reach etcd to register themselves; server-only 
connectivity causes engine startup to fail. With TLS, the drivers also need the 
configured certificate files at the inherited paths, since forwarding 
configuration does not copy them. Document both requirements here and clarify 
the TLS guidance at lines 80–83.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to