<#7705 fix(connector): reuse persistent connection...
# flyte-github
a
#7705 fix(connector): reuse persistent connections for ListConnectors polling Pull request opened by pingsutw Why are the changes needed? The connector metadata poll loop re-dials a brand-new gRPC connection to every connector endpoint on every
PollInterval
(default 10s) and tears it down at the end of each tick. So every
ListConnectors
call pays a full TCP + HTTP/2 handshake through the ingress path (for Knative connector apps this is
ExternalName → kourier-internal → activator → queue-proxy → pod
). In contrast,
GetTask
already reuses a cached, long-lived
AsyncConnectorService
client (
getAsyncConnectorClient
), so it runs over a warm connection. Only the
ListConnectors
metadata path re-connects each poll. This is wasteful (handshake churn every 10s per endpoint) and fragile: a fresh connection is fully exposed to any per-connection-setup latency on the ingress path, and the client had no keepalive, so a dead/half-open transport would only surface via the OS TCP timeout (~13 min on Linux) rather than seconds. Note: this reduces the connection setup ListConnectors is exposed to and adds keepalive; it is a resilience/hygiene improvement. I'm being deliberate that it is not claimed as a proven fix for a specific production stall still under investigation — see "How was this patch tested". What changes were proposed in this pull request? •
watchConnectors
now reuses the persistent connections already held on
Plugin.cs
(built once at init with the plugin's long-lived context) instead of building a throwaway
ClientSet
with a per-tick
context.WithCancel
that closes the connections at the end of each poll. It dials only endpoints not yet connected (e.g. newly-added connector deployments/apps), mirroring how
getAsyncConnectorClient
already caches. • Added
getConnectorMetadataClient
(caches a
ConnectorMetadataService
client per endpoint) and
allConnectorDeployments
(extracts the endpoint-gathering that
getConnectorClientSets
duplicated). • Added conservative client keepalive (
Time: 30s
,
Timeout: 10s
,
PermitWithoutStream
left false to avoid tripping server ping-rate enforcement) so a dead transport is detected in seconds. Behavioral note: connector endpoints removed from config leave an idle cached client on
Plugin.cs
until plugin shutdown (a minor, rare leak); the registry is still rebuilt from current config each poll, so removed connectors stop being queried. How was this patch tested? •
go build
,
go vet
, and the full
webapi/connector
package tests pass. • Added unit tests: •
TestGetConnectorMetadataClientReusesConnection
— an already-cached endpoint reuses the same client (asserts no re-dial/replace); a new endpoint is dialed and cached. •
TestAllConnectorDeployments
— gathers default + deployments + apps. • The keepalive values are conservative defaults and may warrant tuning against the connector server's HTTP/2 ping enforcement. Labels fixed Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. https://claude.ai/code/session_01DRW6WhuHfrCiAXPQ3W1YFA flyteorg/flyte