[PR #6947] [MERGED] [client] parse NB_LAZY_CONN_INACTIVITY_THRESHOLD as a Go duration #29295

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

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6947
Author: @riccardomanfrin
Created: 7/28/2026
Status: Merged
Merged: 7/28/2026
Merged by: @mlsmaycon

Base: mainHead: fix/lazy-conn-inactivity-duration


📝 Commits (2)

  • fd5849e Fixes lazy inactivity threshold env var
  • 52438d1 [client] parse NB_LAZY_CONN_INACTIVITY_THRESHOLD as a Go duration

📊 Changes

2 files changed (+49 additions, -5 deletions)

View changed files

📝 client/internal/conn_mgr.go (+14 -5)
📝 client/internal/conn_mgr_test.go (+35 -0)

📄 Description

Describe your changes

NB_LAZY_CONN_INACTIVITY_THRESHOLD was parsed with strconv.Atoi, i.e. as a bare
integer number of minutes. The documentation, however, states it takes a Go duration
(e.g. 30m, 1h). As a result any documented value such as 30m or 5m failed to
parse and silently fell back to the 15m default, so the setting appeared to have
no effect.

inactivityThresholdEnv() now parses the value with time.ParseDuration, matching
the docs. A bare integer is still accepted as a number of minutes for backwards
compatibility, and an unparseable value logs a warning and falls back to the default.

Added TestInactivityThresholdEnv covering Go-duration values (30m/1h/90s), the
bare-integer minutes fallback, and zero/negative/garbage inputs.

N/A

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 — backwards-compatible bug fix that aligns the env parsing with the already-documented behaviour.

Documentation

Select exactly one:

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

The docs already document the Go-duration format (30m, 1h); this change makes the
code honour it, so no docs update is required.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Inactivity thresholds now support Go duration formats such as 30m, 1h, and 45s.
    • Existing numeric values remain supported and are interpreted as minutes.
    • Invalid or non-positive values now generate a warning and are safely ignored.

🔄 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/6947 **Author:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Created:** 7/28/2026 **Status:** ✅ Merged **Merged:** 7/28/2026 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `fix/lazy-conn-inactivity-duration` --- ### 📝 Commits (2) - [`fd5849e`](https://github.com/netbirdio/netbird/commit/fd5849e8ff66531d987c08addc93ede76578e19d) Fixes lazy inactivity threshold env var - [`52438d1`](https://github.com/netbirdio/netbird/commit/52438d168553fff950345c78bf3bae515d33ad7b) [client] parse NB_LAZY_CONN_INACTIVITY_THRESHOLD as a Go duration ### 📊 Changes **2 files changed** (+49 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/conn_mgr.go` (+14 -5) 📝 `client/internal/conn_mgr_test.go` (+35 -0) </details> ### 📄 Description ## Describe your changes `NB_LAZY_CONN_INACTIVITY_THRESHOLD` was parsed with `strconv.Atoi`, i.e. as a bare integer number of minutes. The documentation, however, states it takes a Go duration (e.g. `30m`, `1h`). As a result any documented value such as `30m` or `5m` failed to parse and **silently fell back to the 15m default**, so the setting appeared to have no effect. `inactivityThresholdEnv()` now parses the value with `time.ParseDuration`, matching the docs. A bare integer is still accepted as a number of minutes for backwards compatibility, and an unparseable value logs a warning and falls back to the default. Added `TestInactivityThresholdEnv` covering Go-duration values (`30m`/`1h`/`90s`), the bare-integer minutes fallback, and zero/negative/garbage inputs. ## Issue ticket number and link N/A ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — backwards-compatible bug fix that aligns the env parsing with the already-documented behaviour. ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) The docs already document the Go-duration format (`30m`, `1h`); this change makes the code honour it, so no docs update is required. <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/netbirdio/codesmith/netbird/pr/6947"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1787843718&installation_model_id=427504&pr_number=6947&repository=netbirdio%2Fnetbird&return_to=https%3A%2F%2Fgithub.com%2Fnetbirdio%2Fnetbird%2Fpull%2F6947&signature=ccca9bdddf6a5e5b061dbcf665d2720ef4a4666cd8872f9d755b50b7f2518579"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Inactivity thresholds now support Go duration formats such as `30m`, `1h`, and `45s`. * Existing numeric values remain supported and are interpreted as minutes. * Invalid or non-positive values now generate a warning and are safely ignored. <!-- 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:49 -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#29295