[PR #6762] [client, management] Support per-peer lazy connection state and default proxy peers to lazy #28922

Open
opened 2026-08-05 08:07:09 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6762
Author: @lixmal
Created: 7/14/2026
Status: 🔄 Open

Base: mainHead: lazy-conn-per-peer


📝 Commits (5)

  • 707bc3e Support per-peer lazy connection state and default proxy peers to lazy
  • e0f275c Classify forward targets from incoming config in lazy exclusion
  • b9489e5 Set IsUserspaceBind mock so lazy manager starts in engine test
  • 06ab0cb Skip lazy exclude reconciliation when the set is unchanged
  • ed309b7 Keep cached lazy flag when a sync carries no peer config

📊 Changes

16 files changed (+1279 additions, -1071 deletions)

View changed files

📝 client/internal/conn_mgr.go (+59 -88)
📝 client/internal/conn_mgr_test.go (+88 -0)
📝 client/internal/engine.go (+52 -36)
📝 client/internal/engine_lazy_exclude_test.go (+4 -2)
📝 client/internal/engine_test.go (+2 -1)
📝 management/internals/shared/grpc/components_encoder.go (+1 -0)
📝 management/internals/shared/grpc/components_encoder_test.go (+3 -3)
📝 management/internals/shared/grpc/components_envelope_response.go (+4 -4)
📝 management/internals/shared/grpc/conversion.go (+3 -2)
📝 management/server/peer/peer.go (+1 -0)
📝 shared/management/networkmap/decode.go (+1 -0)
📝 shared/management/networkmap/encode.go (+16 -2)
📝 shared/management/networkmap/envelope.go (+2 -2)
📝 shared/management/proto/management.pb.go (+1019 -931)
📝 shared/management/proto/management.proto (+21 -0)
📝 shared/management/types/component_types.go (+3 -0)

📄 Description

Describe your changes

Lazy connections were an all-or-nothing account setting. This makes laziness controllable per peer and runs the lazy connection manager continuously, so ephemeral proxy peers connect on-demand by default even when the account-wide flag is off.

  • Run the lazy connection manager whenever it is supported instead of gating it on the account-wide flag; the account flag and the local override now decide which peers default to lazy versus always-active.
  • Add a per-peer lazy override to the network map (default / lazy / eager) so management can steer individual peers in either direction.
  • Default ephemeral proxy peers to lazy on both endpoints, so shared proxy infrastructure is not kept permanently connected to every peer.
  • Keep a local NB_LAZY_CONN / MDM override authoritative over the per-peer state.
  • Reflect the resolved account-wide default in client status and update it when the flag changes at runtime.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

No new user-facing configuration is introduced; the per-peer eager override has no admin-facing setting yet and the proxy-peer default is internal behavior.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features
    • Added per-peer lazy connection control (default/lazy/eager) via management configuration, including embedded proxy–aware lazy behavior.
    • Lazy peer eligibility and exclusions now incorporate ingress forwarding rules end-to-end.
  • Bug Fixes
    • Remote lazy feature-flag updates no longer restart or reconcile lazy peers unnecessarily.
    • Exclude-list updates avoid redundant recomputation when the effective set hasn’t changed.
  • Tests
    • Expanded coverage for per-peer lazy resolution and forwarding-rule-based exclusion behavior, plus updated engine lazy test setup.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6762 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 7/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `lazy-conn-per-peer` --- ### 📝 Commits (5) - [`707bc3e`](https://github.com/netbirdio/netbird/commit/707bc3ea623b67e49de1fdbb0c8834a1437aba50) Support per-peer lazy connection state and default proxy peers to lazy - [`e0f275c`](https://github.com/netbirdio/netbird/commit/e0f275cc60aa9915a44789c9e3cc36978c1c7408) Classify forward targets from incoming config in lazy exclusion - [`b9489e5`](https://github.com/netbirdio/netbird/commit/b9489e5281aaf762d1c7b0064583f481c64e16ef) Set IsUserspaceBind mock so lazy manager starts in engine test - [`06ab0cb`](https://github.com/netbirdio/netbird/commit/06ab0cb3f41bf8ce491d4ff68a532b664590a407) Skip lazy exclude reconciliation when the set is unchanged - [`ed309b7`](https://github.com/netbirdio/netbird/commit/ed309b70f01cae412ce83ba0ab3113f00ec25c61) Keep cached lazy flag when a sync carries no peer config ### 📊 Changes **16 files changed** (+1279 additions, -1071 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/conn_mgr.go` (+59 -88) 📝 `client/internal/conn_mgr_test.go` (+88 -0) 📝 `client/internal/engine.go` (+52 -36) 📝 `client/internal/engine_lazy_exclude_test.go` (+4 -2) 📝 `client/internal/engine_test.go` (+2 -1) 📝 `management/internals/shared/grpc/components_encoder.go` (+1 -0) 📝 `management/internals/shared/grpc/components_encoder_test.go` (+3 -3) 📝 `management/internals/shared/grpc/components_envelope_response.go` (+4 -4) 📝 `management/internals/shared/grpc/conversion.go` (+3 -2) 📝 `management/server/peer/peer.go` (+1 -0) 📝 `shared/management/networkmap/decode.go` (+1 -0) 📝 `shared/management/networkmap/encode.go` (+16 -2) 📝 `shared/management/networkmap/envelope.go` (+2 -2) 📝 `shared/management/proto/management.pb.go` (+1019 -931) 📝 `shared/management/proto/management.proto` (+21 -0) 📝 `shared/management/types/component_types.go` (+3 -0) </details> ### 📄 Description ## Describe your changes Lazy connections were an all-or-nothing account setting. This makes laziness controllable per peer and runs the lazy connection manager continuously, so ephemeral proxy peers connect on-demand by default even when the account-wide flag is off. - Run the lazy connection manager whenever it is supported instead of gating it on the account-wide flag; the account flag and the local override now decide which peers default to lazy versus always-active. - Add a per-peer lazy override to the network map (default / lazy / eager) so management can steer individual peers in either direction. - Default ephemeral proxy peers to lazy on both endpoints, so shared proxy infrastructure is not kept permanently connected to every peer. - Keep a local NB_LAZY_CONN / MDM override authoritative over the per-peer state. - Reflect the resolved account-wide default in client status and update it when the flag changes at runtime. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [ ] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) No new user-facing configuration is introduced; the per-peer eager override has no admin-facing setting yet and the proxy-peer default is internal behavior. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added per-peer lazy connection control (default/lazy/eager) via management configuration, including embedded proxy–aware lazy behavior. * Lazy peer eligibility and exclusions now incorporate ingress forwarding rules end-to-end. * **Bug Fixes** * Remote lazy feature-flag updates no longer restart or reconcile lazy peers unnecessarily. * Exclude-list updates avoid redundant recomputation when the effective set hasn’t changed. * **Tests** * Expanded coverage for per-peer lazy resolution and forwarding-rule-based exclusion behavior, plus updated engine lazy test setup. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:07:09 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28922