Skip to content

[BUG] flagd-proxy: sync stream is severed every ~90s by GOAWAY ENHANCE_YOUR_CALM (missing KeepaliveEnforcementPolicy) #2021

Closed

Description

@yuchou87

Observed behavior

flagd-proxy serves the same FlagSyncService as flagd, but creates its gRPC
server without a KeepaliveEnforcementPolicy. gRPC's defaults therefore apply
(MinTime: 5m, PermitWithoutStream: false), while the official in-process
providers ping every 30s with PermitWithoutStream: true. The server counts
these as ping strikes and tears the connection down with
GOAWAY ENHANCE_YOUR_CALM ("too_many_pings") roughly every 90 seconds.

flagd itself already fixed exactly this — flagd-proxy was missed.

What we observe

Every client pod cycles through provider states roughly every 90–180 seconds:

15:43:15.626  PROVIDER_STALE   "connection error"
15:43:20.627  PROVIDER_ERROR   "provider error"
15:43:27.642  PROVIDER_READY
15:46:28.649  PROVIDER_STALE   "connection error"
15:46:33.649  PROVIDER_ERROR   "provider error"
15:46:40.663  PROVIDER_READY

The intervals are identical to the millisecond across cycles
(STALE→ERROR = 5.000s = defaultGracePeriod, STALE→READY = 12.01s =
RetryBackOffMaxMs), which is what first told us this was a configured timer
rather than network flakiness.

The provider's own log carries the real cause:

sync cycle failed: stream error: rpc error: code = Unavailable
desc = closing transport due to: connection error: desc = "error reading from server: EOF",
received prior goaway: code: ENHANCE_YOUR_CALM, debug data: "too_many_pings"

Root cause

Server side — flagd-proxy/pkg/service/server.go:107:

s.grpcServer = grpc.NewServer()
rpc.RegisterFlagSyncServiceServer(s.grpcServer, s.oldHandler)
syncv1.RegisterFlagSyncServiceServer(s.grpcServer, s.handler)

No ServerOption at all, so gRPC's default enforcement policy applies:
MinTime: 5 * time.Minute, PermitWithoutStream: false. The 5-minute MinTime
against a 30-second client ping is the part that actually causes the disconnects.

Client side — go-sdk-contrib/providers/flagd/pkg/service/in_process/grpc_sync.go:130:

keepaliveParams := keepalive.ClientParameters{
    Time:                30 * time.Second, // defaultKeepaliveTime
    Timeout:             5 * time.Second,  // defaultKeepaliveTimeout
    PermitWithoutStream: true,
}

These are package-level constants with no provider option to override them.

Walking grpc-go's http2_server.go (handlePing): because the SyncFlags
stream is long-lived, len(t.activeStreams) >= 1, so the accounting takes the
else branch and compares against kep.MinTime — PermitWithoutStream is not
what bites here, MinTime alone is
. Each ping arriving sooner than MinTime
increments pingStrikes, and GOAWAY is sent once pingStrikes > maxPingStrikes
(maxPingStrikes = 2), i.e. on the third strike: pings at t=30s/60s/90s → GOAWAY
at ~90s, which is what we measure.

resetPingStrikes clears the counter whenever the server sends data, which is why
the interval stretches to ~180s on a flag set that is being updated and stays near
90s on an idle one.

This was already fixed in flagd — flagd-proxy was left out

This is not a new proposal. The exact same problem was reported and fixed for
flagd's flag-sync server in
#1998 (opened 2026-07-14, closed
as completed 2026-07-16), and surfaced on the operator side in
open-feature-operator#852
(merged 2026-07-31). #852 states its scope explicitly — "Both the injected sidecar
and the standalone Flagd ... pick this up through the shared injection path"
— and
never mentions flagd-proxy.

flagd-proxy serves the same FlagSyncService to the same clients over the same
long-lived streams, so it needs the same policy. As of bbb05d4 (2026-07-31, i.e.
after both of the above landed), flagd-proxy/pkg/service/server.go:107 and :123 are
still bare grpc.NewServer() calls with no keepalive enforcement policy and no CLI
flags to set one.

flagd/pkg/service/flag-sync/sync_service.go:71 — note the comment:

// keepAliveEnforcementPolicy builds the gRPC keepalive enforcement policy so
// provider keepalive pings on the long-lived SyncFlags stream aren't rejected
// with GOAWAY ENHANCE_YOUR_CALM.
func keepAliveEnforcementPolicy(cfg SvcConfigurations) keepalive.EnforcementPolicy {
    return keepalive.EnforcementPolicy{
        MinTime:             cfg.KeepAliveMinTime,
        PermitWithoutStream: cfg.KeepAlivePermitWithoutStream,
    }
}

wired in via grpc.KeepaliveEnforcementPolicy(...), and exposed as
--keep-alive-min-time (default 30s) and
--keep-alive-permit-without-stream (default true) in flagd/cmd/start.go:102.

Those defaults match the client's behaviour exactly. flagd-proxy has neither the
server option nor the flags — its CLI only accepts --port, --management-port
and --log-format.

Impact

For in-process providers the flag rules stay in memory, so evaluation keeps
working throughout
— this is not an availability problem. What it does cost:

  • Rule propagation stalls for up to ~12s per disconnect. Note the 12s is not
    reconnect latency: after a stream-level failure the provider sleeps the full
    RetryBackOffMaxMs (grpc_sync.go) instead of retrying with the initial backoff.
  • Provider state alarms are unusable. With one provider a pod sits in
    stale/error roughly 4–8% of the time. Anything alerting on provider state
    fires continuously. Consumers subscribing to two flag sets see double the events.
  • Log noise: one ERROR-level provider event per stream per ~90–180s per pod.

Workarounds we evaluated (none are viable)

  • open-feature-operator: FeatureFlagSource.keepAliveMinTime /
    keepAlivePermitWithoutStream exist, but ToEnvVars() emits
    FLAGD_KEEP_ALIVE_* for the injected flagd sidecar only. The flagd-proxy
    deployment never receives them, and OFO hardcodes its args to
    start --management-port <n> — which flagd-proxy would reject anyway.
  • Client-side tuning: defaultKeepaliveTime is a package constant with no
    ProviderOption. WithGrpcDialOptionsOverride fully replaces
    buildDialOptions(), so using it means reimplementing transport credentials,
    max message size and the retry service config, and re-diverging on every
    provider upgrade.
  • WithRetryBackoffMaxMs: shortens the degraded window but does not stop the
    disconnects.

Expected Behavior

The sync stream should stay up. flagd-proxy serves the same FlagSyncService to
the same providers as flagd, so it should enforce the same keepalive policy —
MinTime: 30s, PermitWithoutStream: true — and expose the same two flags, so
that client and server agree without anyone having to configure either side.

Proposed fix

Mirror what flagd already does — add the enforcement policy to flagd-proxy's
gRPC server, with the same defaults so client and server agree out of the box.
Happy to open the PR if the approach looks right.

Steps to reproduce

flagd-proxy needs no special configuration to reproduce this — the defaults are
enough. Any deployment serving at least one long-lived SyncFlags stream to an
official in-process provider will show it.

  1. Run flagd-proxy start (no keepalive flags exist, so nothing to set).
  2. Point a Go in-process flagd provider at it — flagd.WithInProcessResolver()
    against the proxy's sync port. The provider's defaults are what matter:
    it pings every 30s with PermitWithoutStream: true, and neither is
    overridable through a ProviderOption.
  3. Keep the stream open and watch the provider's events and logs.

Within ~90 seconds the stream is torn down with
GOAWAY ENHANCE_YOUR_CALM ("too_many_pings") and the provider cycles
STALE → ERROR → READY. On a flag set that is being updated the interval
stretches to ~180s, because resetPingStrikes clears the counter whenever the
server sends data.

Reproducing it without Kubernetes is also possible: build any gRPC server with a
bare grpc.NewServer(), connect a client with keepalive.ClientParameters{Time: 10 * time.Second, PermitWithoutStream: true} over a long-lived stream, and the
server sends GOAWAY on the third ping.

Environment
Version
flagd-proxy v0.9.4 (the default pinned by open-feature-operator)
open-feature-operator deploys flagd-proxy automatically, FLAGD_PROXY_TAG default v0.9.4
Client go-sdk-contrib/providers/flagd v0.6.0, in-process resolver
OpenFeature Go SDK v1.17.2
Platform GKE, in-cluster plaintext gRPC to flagd-proxy-svc:8015

Activity

  1. added
    bug
    Needs Triage
    on Aug 14, 2026
  2. added a commit that references this issue on Aug 18, 2026
    5591fa8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Triagebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions