[PR #6617] [MERGED] [client] Make lazy connections opt-out via NB_LAZY_CONN #29729

Closed
opened 2026-08-05 08:08:48 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6617
Author: @lixmal
Created: 6/30/2026
Status: Merged
Merged: 7/2/2026
Merged by: @lixmal

Base: mainHead: lazy-conn-opt-out


📝 Commits (3)

  • 159e573 Make lazy connections opt-out with NB_LAZY_CONN and MDM overrides
  • a007c45 Recognize lazyConnection MDM key on desktop and read it as a bool
  • 9be9f0d Normalize MDM bool string values case-insensitively

📊 Changes

26 files changed (+309 additions, -151 deletions)

View changed files

📝 client/android/env_list.go (+1 -1)
📝 client/cmd/root.go (+10 -7)
📝 client/cmd/up.go (+0 -10)
📝 client/internal/auth/auth.go (+0 -1)
📝 client/internal/conn_mgr.go (+46 -9)
client/internal/conn_mgr_test.go (+40 -0)
📝 client/internal/connect.go (+2 -2)
📝 client/internal/debug/debug.go (+1 -1)
📝 client/internal/debug/debug_test.go (+1 -1)
📝 client/internal/engine.go (+4 -3)
📝 client/internal/lazyconn/env.go (+42 -9)
client/internal/lazyconn/env_test.go (+45 -0)
📝 client/internal/profilemanager/config.go (+12 -9)
📝 client/internal/profilemanager/config_mdm_test.go (+31 -0)
📝 client/ios/NetBirdSDK/env_list.go (+1 -1)
📝 client/mdm/canonical_loaders.go (+1 -0)
📝 client/mdm/policy.go (+11 -3)
📝 client/mdm/policy_test.go (+9 -4)
📝 client/server/mdm.go (+0 -3)
📝 client/server/server.go (+0 -3)

...and 6 more files

📄 Description

Describe your changes

Lazy connections are becoming the default (enabled by management for new accounts in #6571). This reworks the client-side control so lazy is opt-out, driven by management with explicit local overrides, and removes the old experimental opt-in.

Resolution order: NB_LAZY_CONN env var (if set) > MDM policy override > management feature flag > off.

  • Add the tri-state NB_LAZY_CONN env var (on/off/unset); set, it overrides the management feature flag in both directions; unset defers to management
  • Add an MDM policy override (lazyConnection key, on/off) with the same semantics, below the env var
  • Remove the experimental NB_ENABLE_EXPERIMENTAL_LAZY_CONN variable
  • Retire the --enable-lazy-connection CLI flag: inert and hidden (kept so existing invocations don't error)
  • Remove the local LazyConnectionEnabled setting end to end (config, daemon apply, desktop UI checkbox, MDM bool, and login telemetry); lazy is no longer a persisted local toggle
  • Point the Android/iOS env exports at the new variable name

The per-peer lazy flag previously reported to management via login metadata is no longer sent (it reflected the removed local setting). Runtime lazy status in netbird status is unaffected.

Complements #6571.

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)

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/821

Summary by CodeRabbit

  • New Features
    • Lazy connections are now controlled via NB_LAZY_CONN (on/off/unset), with unset deferring to management using consistent precedence.
    • Added MDM policy support for lazyConnection, including normalization of on/off/yes/no values.
  • Bug Fixes
    • Local overrides reliably take priority; remote changes and related status updates are ignored when overridden.
  • UI / CLI
    • Removed the lazy-connections toggle from the tray UI and settings sync.
    • Deprecated --enable-lazy-connection; it’s no longer used by up.
  • Tests / Other
    • Expanded unit test coverage for env parsing, override resolution, and MDM mapping; updated debug output.

🔄 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/6617 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 6/30/2026 **Status:** ✅ Merged **Merged:** 7/2/2026 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `main` ← **Head:** `lazy-conn-opt-out` --- ### 📝 Commits (3) - [`159e573`](https://github.com/netbirdio/netbird/commit/159e5736cd631a5a7c9aa886fdfc9e9ea1106975) Make lazy connections opt-out with NB_LAZY_CONN and MDM overrides - [`a007c45`](https://github.com/netbirdio/netbird/commit/a007c45883747be8f000af4ebb5e77a799db252d) Recognize lazyConnection MDM key on desktop and read it as a bool - [`9be9f0d`](https://github.com/netbirdio/netbird/commit/9be9f0d248f4f322821056dfb6974ba2abdaede2) Normalize MDM bool string values case-insensitively ### 📊 Changes **26 files changed** (+309 additions, -151 deletions) <details> <summary>View changed files</summary> 📝 `client/android/env_list.go` (+1 -1) 📝 `client/cmd/root.go` (+10 -7) 📝 `client/cmd/up.go` (+0 -10) 📝 `client/internal/auth/auth.go` (+0 -1) 📝 `client/internal/conn_mgr.go` (+46 -9) ➕ `client/internal/conn_mgr_test.go` (+40 -0) 📝 `client/internal/connect.go` (+2 -2) 📝 `client/internal/debug/debug.go` (+1 -1) 📝 `client/internal/debug/debug_test.go` (+1 -1) 📝 `client/internal/engine.go` (+4 -3) 📝 `client/internal/lazyconn/env.go` (+42 -9) ➕ `client/internal/lazyconn/env_test.go` (+45 -0) 📝 `client/internal/profilemanager/config.go` (+12 -9) 📝 `client/internal/profilemanager/config_mdm_test.go` (+31 -0) 📝 `client/ios/NetBirdSDK/env_list.go` (+1 -1) 📝 `client/mdm/canonical_loaders.go` (+1 -0) 📝 `client/mdm/policy.go` (+11 -3) 📝 `client/mdm/policy_test.go` (+9 -4) 📝 `client/server/mdm.go` (+0 -3) 📝 `client/server/server.go` (+0 -3) _...and 6 more files_ </details> ### 📄 Description ## Describe your changes Lazy connections are becoming the default (enabled by management for new accounts in #6571). This reworks the client-side control so lazy is opt-out, driven by management with explicit local overrides, and removes the old experimental opt-in. Resolution order: `NB_LAZY_CONN` env var (if set) > MDM policy override > management feature flag > off. - Add the tri-state `NB_LAZY_CONN` env var (`on`/`off`/unset); set, it overrides the management feature flag in both directions; unset defers to management - Add an MDM policy override (`lazyConnection` key, `on`/`off`) with the same semantics, below the env var - Remove the experimental `NB_ENABLE_EXPERIMENTAL_LAZY_CONN` variable - Retire the `--enable-lazy-connection` CLI flag: inert and hidden (kept so existing invocations don't error) - Remove the local `LazyConnectionEnabled` setting end to end (config, daemon apply, desktop UI checkbox, MDM bool, and login telemetry); lazy is no longer a persisted local toggle - Point the Android/iOS env exports at the new variable name The per-peer lazy flag previously reported to management via login metadata is no longer sent (it reflected the removed local setting). Runtime lazy status in `netbird status` is unaffected. ## Issue ticket number and link Complements #6571. ## 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: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### 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/821 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Lazy connections are now controlled via `NB_LAZY_CONN` (`on`/`off`/unset), with unset deferring to management using consistent precedence. * Added MDM policy support for `lazyConnection`, including normalization of `on/off/yes/no` values. * **Bug Fixes** * Local overrides reliably take priority; remote changes and related status updates are ignored when overridden. * **UI / CLI** * Removed the lazy-connections toggle from the tray UI and settings sync. * Deprecated `--enable-lazy-connection`; it’s no longer used by `up`. * **Tests / Other** * Expanded unit test coverage for env parsing, override resolution, and MDM mapping; updated debug output. <!-- 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:08:48 -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#29729