Skip to content

Fix HTTP/2 keep-alive channel options - #268

Merged
Marenz merged 1 commit into
frequenz-floss:v0.x.xfrom
Marenz:add-dependabot-workflow
Aug 12, 2026
Merged

Fix HTTP/2 keep-alive channel options#268
Marenz merged 1 commit into
frequenz-floss:v0.x.xfrom
Marenz:add-dependabot-workflow

Conversation

@Marenz

@Marenz Marenz commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

grpc.keepalive_time_ms and grpc.keepalive_timeout_ms were passed as float.
grpc-python silently ignores channel arguments that are neither int nor str,
so keep-alive had never actually been armed.

The regression test asserts the exact argument types, because value equality alone
does not distinguish 60000 from 60000.0.

Verified with grpc-python keepalive traces and TCP lastsnd: the patched channel
emitted pings at the configured interval. Keep-alive only proves that the nearest
HTTP/2 peer is alive, so terminating proxies need their own backend liveness handling.

Checks: uv run nox -R -s formatting flake8 mypy pylint pytest_max (133 tests passed).

@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:code Affects the code in general labels Aug 11, 2026
@Marenz
Marenz force-pushed the add-dependabot-workflow branch from 7dd163e to f481515 Compare August 11, 2026 14:29
@Marenz
Marenz marked this pull request as ready for review August 11, 2026 14:31
@Marenz
Marenz requested review from llucax and a lite review from Copilot August 11, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes gRPC channel construction so HTTP/2 keep-alive is actually applied (by ensuring channel args are passed as int milliseconds) and adds support for connecting to an explicit IPv4/IPv6 socket address while preserving the original URI hostname for HTTP/2 authority and TLS verification.

Changes:

  • Convert keep-alive interval/timeout to integer milliseconds to avoid grpc-python silently ignoring float channel args.
  • Introduce ChannelOptions.connection_address to connect to a specific IP while retaining the URI hostname via gRPC authority/TLS override options.
  • Extend tests to cover address overrides and to assert keep-alive arg types.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/frequenz/client/base/channel.py Adds connection-address override support and ensures keep-alive options are emitted as int milliseconds.
tests/test_channel.py Adds regression coverage for keep-alive argument types and connection-address override behavior/validation.
RELEASE_NOTES.md Documents the keep-alive fix and the new connection-address override feature.
AGENTS.md Adds repository agent guidance (build/test commands, conventions, architecture notes).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/frequenz/client/base/channel.py Outdated
Comment thread tests/test_channel.py
@Marenz
Marenz force-pushed the add-dependabot-workflow branch from f481515 to 6d1af36 Compare August 11, 2026 14:39
Comment thread RELEASE_NOTES.md
Comment thread src/frequenz/client/base/channel.py Outdated
Comment thread AGENTS.md Outdated
@Marenz Marenz changed the title Fix gRPC keepalive and connection overrides Fix HTTP/2 keepalive channel options Aug 12, 2026
@Marenz
Marenz requested a review from llucax August 12, 2026 11:57
`grpc.keepalive_time_ms` and `grpc.keepalive_timeout_ms` were computed
with `timedelta.total_seconds() * 1000`, which yields a `float`.
grpc-python silently ignores channel arguments whose value is neither
`int` nor `str`, so keep-alive was never armed: no pings were sent and a
client could only notice a dead stream through its own deadline or a
teardown from the peer.

Convert both durations to whole milliseconds via a small `_to_millis`
helper. The regression test asserts the exact argument type, because
value equality does not distinguish `60000` from `60000.0`.

Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
@Marenz
Marenz force-pushed the add-dependabot-workflow branch from 90c205d to 0e66abc Compare August 12, 2026 12:04
@Marenz Marenz changed the title Fix HTTP/2 keepalive channel options Fix HTTP/2 keep-alive channel options Aug 12, 2026
@Marenz
Marenz added this pull request to the merge queue Aug 12, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit a32b66c Aug 12, 2026
9 checks passed
@Marenz
Marenz deleted the add-dependabot-workflow branch August 12, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:code Affects the code in general part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants