Skip to content

feat: expose HTTP/2 connection keepalive in BackendConfigPolicy#14367

Merged
davidjumani merged 2 commits into
kgateway-dev:mainfrom
Tazmainiandevil:feat/backendconfigpolicy-http2-connection-keepalive
Jul 13, 2026
Merged

feat: expose HTTP/2 connection keepalive in BackendConfigPolicy#14367
davidjumani merged 2 commits into
kgateway-dev:mainfrom
Tazmainiandevil:feat/backendconfigpolicy-http2-connection-keepalive

Conversation

@Tazmainiandevil

@Tazmainiandevil Tazmainiandevil commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #14381.

Adds connectionKeepalive to BackendConfigPolicy.spec.http2ProtocolOptions, mapping to Envoy's Http2ProtocolOptions.connection_keepalive:

http2ProtocolOptions:
  connectionKeepalive:
    timeout: 5s                    # required; close if PING unacknowledged
    interval: 30s                  # optional; periodic PINGs
    connectionIdleInterval: 60s    # optional; PING before reusing an idle connection

Motivation

Long-lived upstream HTTP/2 / gRPC connections can go half-dead — TCP-alive but HTTP/2-dead (NAT/LB state loss, wedged remote process). tcpKeepalive covers the OS layer but cannot detect this class; HTTP/2 PING keepalive is the protocol-level complement, and failures surface in the http2.keepalive_timeout cluster stat for alerting. This was previously requested in #3740 (closed by stalebot in the gloo era).

What's included

  • API: ConnectionKeepalive type (required timeout, optional interval / connectionIdleInterval), CEL duration validation consistent with tcpKeepalive
  • Translation in the backendconfigpolicy plugin to envoycorev3.KeepaliveSettings
  • Generated deepcopy + CRD manifest (make go-generate-apis)
  • Unit test (translation) + API validation e2e case (CEL rules)

Merging of http2ProtocolOptions is unchanged — the block is already merged as a unit, so the new field participates automatically.

Change Type

/kind new_feature

Changelog

Added `connectionKeepalive` to `BackendConfigPolicy.spec.http2ProtocolOptions`, enabling Envoy HTTP/2 keepalive PINGs for active half-dead upstream connection detection.

🤖 Generated with Claude Code

Adds connectionKeepalive (timeout, interval, connectionIdleInterval) to
http2ProtocolOptions, mapping to Envoy's
Http2ProtocolOptions.connection_keepalive (KeepaliveSettings). Enables
active half-dead-connection detection for long-lived upstream HTTP/2 and
gRPC connections: Envoy sends keepalive PINGs and closes the connection
if no response arrives within the timeout, surfacing in the
http2.keepalive_timeout stat.

Previously requested in kgateway-dev#3740 (closed stale). tcpKeepalive covers the
OS/TCP layer but cannot detect peers that are TCP-alive yet HTTP/2-dead
(e.g. after NAT/LB state loss or a wedged remote process); HTTP/2 PING
keepalive is the protocol-level complement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Mark Johnson <[email protected]>
@Tazmainiandevil
Tazmainiandevil requested a review from a team as a code owner July 8, 2026 13:14
Copilot AI review requested due to automatic review settings July 8, 2026 13:14
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note labels Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends kgateway’s BackendConfigPolicy HTTP/2 upstream configuration surface by adding spec.http2ProtocolOptions.connectionKeepalive, translating it into Envoy’s Http2ProtocolOptions.connection_keepalive to support HTTP/2 PING-based keepalive (half-dead connection detection) for long-lived upstream connections (e.g., gRPC).

Changes:

  • Added ConnectionKeepalive API type under BackendConfigPolicy.spec.http2ProtocolOptions with CEL validation (required timeout, optional interval and connectionIdleInterval).
  • Implemented translation to envoycorev3.KeepaliveSettings and applied it to HTTP/2 backends.
  • Updated generated artifacts (deepcopy + CRD) and added/updated translation + API validation tests.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/e2e/tests/apivalidation/apivalidation.go Adds API validation coverage for invalid connectionKeepalive duration inputs.
pkg/kgateway/extensions2/plugins/backendconfigpolicy/protocoloptions.go Translates connectionKeepalive into Envoy KeepaliveSettings in HTTP/2 protocol options.
pkg/kgateway/extensions2/plugins/backendconfigpolicy/plugin_test.go Adds a unit test asserting the Envoy cluster config includes connection_keepalive for HTTP/2 backends.
install/helm/kgateway-crds/templates/gateway.kgateway.dev_backendconfigpolicies.yaml Updates CRD schema to include connectionKeepalive and its validations.
api/v1alpha1/kgateway/zz_generated.deepcopy.go Adds generated deepcopy support for the new ConnectionKeepalive type/field.
api/v1alpha1/kgateway/backend_config_policy_types.go Introduces ConnectionKeepalive type and wires it into Http2ProtocolOptions.
Files not reviewed (1)
  • api/v1alpha1/kgateway/zz_generated.deepcopy.go: Generated file

Comment thread test/e2e/tests/apivalidation/apivalidation.go
… interval

Matches the retry.perTryTimeout precedent: an unparseable duration fails
both the format-regex rule and the duration() comparison rule, and the
API server reports both.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Mark Johnson <[email protected]>
@Tazmainiandevil

Copy link
Copy Markdown
Contributor Author

Filed #14381 as the accompanying feature issue for visibility/discussion.

@davidjumani
davidjumani added this pull request to the merge queue Jul 13, 2026
Merged via the queue into kgateway-dev:main with commit fd54e6b Jul 13, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BackendConfigPolicy: expose HTTP/2 connection keepalive (KeepaliveSettings) for upstream half-dead connection detection

5 participants