add service discovery for REST frontend with ZK/ETCD support#7429
add service discovery for REST frontend with ZK/ETCD support#7429ychris78 wants to merge 2 commits intoapache:masterfrom
Conversation
|
In practice, it's usually to use a gateway like nginx for HA of HTTP services. |
Thanks for the suggestion. I agree that a reverse proxy like nginx is a common approach for HTTP HA, but I think client-side service discovery via ZK/ETCD offers several unique advantages in Kyuubi's context:
|
Why are the changes needed?
Currently, the Kyuubi REST frontend service does not register itself with the HA discovery service (ZK/ETCD). This means REST clients must use static host URLs and cannot benefit from dynamic service discovery, automatic failover, or load balancing that the Thrift frontend already
supports.
This patch adds full service discovery support for the REST frontend, covering both the server-side (registering REST endpoints in ZK/ETCD under a dedicated namespace) and the client-side (discovering and dynamically refreshing REST endpoints).
Server-side changes:
KyuubiRestFrontendServicenow creates aKyuubiRestServiceDiscoverywhen HA is configured, registering the REST service under{namespace}/rest(e.g./kyuubi/rest) to distinguish it from Thrift endpoints.KyuubiRestServiceDiscoveryextendsServiceDiscoverywith custom namespace logic and graceful shutdown.ServiceDiscovery._namespaceand_discoveryClientvisibility changed fromprivatetoprotectedto allow subclass customization.Client-side changes:
RestDiscoveryConfconfiguration class for ZK/ETCD discovery settings (addresses, namespace, client class, refresh interval).RestServiceDiscovererutility to discover REST host URLs from ZK/ETCD service nodes.KyuubiRestClient.discoveryBuilder()API to create a client with automatic background endpoint refresh.RetryableRestClientrefactored to track the current URI by value instead of index, with a newupdateUris()method for dynamic URI list updates.How was this patch tested?
Unit tests added:
RetryableRestClientTest— testsupdateUris()behavior: keeping current server, switching when removed, URI rotation.RestDiscoveryConfTest— tests default values, setters, and validation logic.RestServiceDiscovererTest— tests namespace construction and validation.Integration tests added:
KyuubiRestServiceDiscoverySuite— tests with embedded ZooKeeper:namespace/restand can be discovered.Compiled and tested
kyuubi-ha,kyuubi-rest-client, andkyuubi-servermodules (mvn compileandmvn testall passed).Was this patch authored or co-authored using generative AI tooling?
co-authored