Repository navigation
feat: extend keepalive to support multiple WireGuard interfaces - #3340
Closed
MircoBarone wants to merge 2 commits into
Closed
MircoBarone wants to merge 2 commits into
MircoBarone wants to merge 2 commits into
Conversation
Collaborator
|
Hi @MircoBarone. Thanks for your PR! I am @adamjensenbot.
Make sure this PR appears in the liqo changelog, adding one of the following labels:
|
16 of 17 tasks
MircoBarone
force-pushed
the
PR9-multitunnel-keepalive-bis
branch
2 times, most recently
from
July 25, 2026 23:11
ab7e387 to
24e9bff
Compare
MircoBarone
marked this pull request as draft
July 25, 2026 23:17
Keep using client.Status().Patch with client.Apply since migrating to ApplyConfiguration requires generated types and is outside the scope of this PR.
MircoBarone
force-pushed
the
PR9-multitunnel-keepalive-bis
branch
from
July 27, 2026 14:44
24e9bff to
e10bd45
Compare
MircoBarone
marked this pull request as ready for review
July 27, 2026 15:01
MircoBarone
marked this pull request as draft
August 19, 2026 10:27
Contributor
Author
|
Closed in favor of #3373 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview and Motivation
Part of the multi-tunnel WireGuard implementation (9th PR related to #3225).
Liqo currently monitors the health of a single WireGuard interface through its keepalive mechanism. Periodic keepalive packets allow measuring interface latency and detecting connectivity failures, exposing this information through the
Connectionresource.With the introduction of multiple parallel WireGuard tunnels, the keepalive mechanism must be extended to monitor each tunnel independently. Since different tunnels may experience different network conditions, the
Connectionresource must expose the status of each individual tunnel while still providing a global view of the connection.Connection resource changes
The
Connectionresource has been extended by introducing astatus.tunnelsfield containing one status entry for each WireGuard interface.Each entry stores:
The global connection fields (
status.valueandstatus.latency) are still exposed, but they are now computed independently by the Connection Aggregator controller.Keepalive changes
The keepalive subsystem is composed of two actors:
PINGmessages containing a timestamp;PINGmessages withPONGmessages and computes the latency when receiving aPONG.Although the existing implementation already supported multiple senders, they were identified by the remote
ClusterID, reflecting an older architecture where a gateway could communicate with multiple remote gateways.This existing design has been reused by replacing the
ClusterIDwith the WireGuardInterfaceID. As a result, every tunnel owns an independent sender.To support this, the gateway container now receives a new
--num-interfacesflag, populated automatically by the deployment templates according to the configured number of WireGuard interfaces. This determines how many keepalive senders are created. The introduction of this flag overlaps with PR #3338, where it is described in greater detail.A new callback,
UpdateTunnelStatus, is called when aPONGis received and updates the status of a single tunnel in theConnectionresource. Updates are performed using Server-Side Apply (SSA), assigning the interface name as the field manager so that every tunnel independently owns its corresponding entry instatus.tunnels.Tunnel updates are throttled to avoid unnecessary API writes. An update is skipped if the tunnel status has not changed and the previous update was performed less than
PingUpdateStatusIntervalago.The keepalive implementation has also been improved to process received messages concurrently:
Connection aggregation
A new
ConnectionAggregatorcontroller computes the global connection status from the individual tunnel states.The aggregation policy is intentionally conservative:
Errorstate;In the Connected state, the global latency is computed as the average latency across all tunnels.
The controller reconciles whenever the
status.tunnelsfield of theConnectionresource changes, either because a tunnel status is updated or because tunnels are added or removed. It computes the aggregated connection state and updates the global connection fields through theUpdateConnectionStatusAggregatedcallback.Like tunnel updates, the aggregated status is written using Server-Side Apply (SSA), but with a dedicated field manager. This cleanly separates ownership between the per-tunnel entries and the aggregated connection fields.
Tunnel initialization and reconciliation
EnsureConnection(), called by thePublicKeyscontroller, invokesreconcileTunnelsStatus()to reconcile thestatus.tunnelsfield with the currently configured WireGuard interfaces.Missing tunnel entries are initialized in the
Connectingstate while waiting for the first successful keepalive exchange. Conversely, stale entries left from previous gateway configurations (for example after reducing the number of tunnels) are removed from theConnectionresource.Note about SSA
client.Applyis deprecated, but migrating toclient.SubResource("status").Apply()requires generatedApplyConfigurationtypes. Since introducing those generated types is outside the scope of this PR, the existing SSA implementation has been kept. Temporary//nolint:staticcheckdirectives have been added to document this decision and suppress the deprecation warnings until a dedicated migration is performed.