Skip to content

docs: clarify config precedence for the combined netbird-server - #1091

Open
jnfrati wants to merge 2 commits into
mainfrom
jnfrati/combined-config-env-docs
Open

jnfrati wants to merge 2 commits into
mainfrom
jnfrati/combined-config-env-docs

Conversation

@jnfrati

@jnfrati jnfrati commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Companion to netbirdio/netbird#8108, which moves the combined netbird-server onto a Viper-backed config loader. That PR doesn't change behavior: CombinedConfig opts no fields into environment or flag overrides, so config.yaml values still come only from the file and defaults. Its tests check that NB_-prefixed variables such as NB_SERVER_LOGLEVEL don't override the file.

The Variable Precedence section of Environment Variables said the reverse, listing "Configuration file → Environment variables → Command-line flags" for the combined setup too. This PR:

  • Scopes the existing precedence list to the older multi-container setup (management.json).
  • Documents the combined server: config.yaml keys are read only from the file and defaults, and NB_ variables named after those keys are ignored.
  • Documents the store exception: at startup, netbird-server copies server.store.* and server.activityStore.* fields from config.yaml into the matching NB_STORE_* / NB_ACTIVITY_EVENT_* variables, so config.yaml wins. A table lists each field and its variable (from combined/cmd/root.go).
  • Adds a one-line note where the configuration-files and Postgres store pages show the DSN environment variable, linking to the precedence section.

Testing

  • Checked against #8108's diff (combined/cmd/config.go, config_test.go) and the store env handling in combined/cmd/root.go on feature/combined-config-loader.
  • npm run build and npm run lint:mdx pass.

Summary by CodeRabbit

  • Documentation
    • Clarified configuration precedence for older multi-container deployments and the combined server setup, including which settings take priority when values are supplied in multiple places.
    • Documented the environment-variable mappings for store and activity-store settings, and explained when container variables are used.
    • Updated external database and PostgreSQL setup instructions to clarify that the configured value takes precedence when both configuration sources specify a store DSN.

config.yaml values are not overridable via NB_ environment variables on the
combined server, and config.yaml store fields overwrite the matching store
environment variables at startup. Fix the Variable Precedence section and note
the DSN precedence where the env-var alternative is shown.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Nov 5, 2026 11:43am UTC

Request Review

@claude claude Bot 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The self-hosted documentation clarifies environment-variable precedence for older multi-container and combined deployments. Two maintenance pages also state that config.yaml takes precedence over the environment-variable PostgreSQL DSN.

Changes: Self-hosted configuration documentation

Layer / File(s) Summary
Document configuration precedence
src/pages/selfhosted/environment-variables.mdx, src/pages/selfhosted/maintenance/configuration-files.mdx, src/pages/selfhosted/maintenance/postgres-store.mdx
The guide distinguishes precedence rules for older multi-container and combined deployments, including store settings. The two maintenance pages state that config.yaml takes precedence when both it and the environment variable set a PostgreSQL DSN.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Suggested reviewers: braginini

Merge Risk: Minimal · up to d8f71

The documentation clarifies combined-server configuration precedence without an identified deployment-impacting error. No concrete merge-blocking issue remains.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "docs: clarify config precedence for the combined netbird-server" matches the main change. The PR scopes the existing precedence documentation to the older multi-container setup and document…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "docs: clarify config precedence for the combined netbird-server" matches the main change. The PR scopes the existing precedence documentation to the older multi-container setup and documents that config.yaml values and built-in defaults apply in the combined netbird-server setup. It also adds DSN precedence notes that link to the precedence section. The title is short, specific, and uses the docs prefix to show the change type.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (3 skipped: 3 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the config with care,
And finds which values take the chair.
Old containers keep their ordered way,
While YAML leads where stores hold sway.
The docs now make the rules clear.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d7659b2d-fec1-41fc-9a7e-e5e2224ac725
Commits

Reviewing files that changed from the base of the PR and between 3befd09 and d8f7156.

Files selected for processing: 3

  • src/pages/selfhosted/environment-variables.mdx
  • src/pages/selfhosted/maintenance/configuration-files.mdx
  • src/pages/selfhosted/maintenance/postgres-store.mdx

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@SunsetDrifter SunsetDrifter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against v0.83.0 source and the netbirdio/netbird-server:0.83.0 image.

  1. Merge main: "Combined Server Variables" (#1079) documents NB_AUTH_SECRET and NB_STORE_ENCRYPTION_KEY overriding config.yaml from v0.83.0 (netbirdio/netbird#8405). Lines 286 and 288 contradict it.
  2. MySQL was removed in v0.82.0 (netbirdio/netbird#7914); only the Postgres DSN is copied (combined/cmd/root.go:131-138).
  3. server.accessLogStore.* is copied the same way (root.go:159-169) and is missing from the table.
  4. Line 298 is false for the activity DSN: activityStore.engine: postgres with an empty dsn fails to start, and a dsn without an engine is ignored.
  5. Scope to v0.83.0: netbirdio/netbird#8515 reverses this. netbird-server --help already claims NB_SERVER_LOGLEVEL works (root.go:60-61).

3. Environment variables
4. Command-line flags

The combined `netbird-server` reads `config.yaml` values only from the file and its built-in defaults. `NB_` environment variables named after `config.yaml` keys, such as `NB_SERVER_LOGLEVEL`, are ignored.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The combined `netbird-server` reads `config.yaml` values only from the file and its built-in defaults. `NB_` environment variables named after `config.yaml` keys, such as `NB_SERVER_LOGLEVEL`, are ignored.
In v0.83.0 and earlier, the combined `netbird-server` reads `config.yaml` values only from the file and its built-in defaults. `NB_` environment variables named after `config.yaml` keys, such as `NB_SERVER_LOGLEVEL`, are ignored. The exceptions, from v0.83.0, are `NB_AUTH_SECRET` and `NB_STORE_ENCRYPTION_KEY`, which override `config.yaml`. See [Combined Server Variables](#combined-server-variables).


The combined `netbird-server` reads `config.yaml` values only from the file and its built-in defaults. `NB_` environment variables named after `config.yaml` keys, such as `NB_SERVER_LOGLEVEL`, are ignored.

The store variables are the exception, and there `config.yaml` wins. At startup, `netbird-server` copies these `config.yaml` fields into the matching environment variables, replacing any value set on the container:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The store variables are the exception, and there `config.yaml` wins. At startup, `netbird-server` copies these `config.yaml` fields into the matching environment variables, replacing any value set on the container:
For the store fields below, `config.yaml` wins. At startup, `netbird-server` copies them into the matching environment variables, replacing any value set on the container:

Comment on lines +292 to +296
| `server.store.dsn` (when `server.store.engine` is `postgres` or `mysql`) | `NB_STORE_ENGINE_POSTGRES_DSN` or `NB_STORE_ENGINE_MYSQL_DSN` |
| `server.store.file` | `NB_STORE_ENGINE_SQLITE_FILE` |
| `server.activityStore.engine` | `NB_ACTIVITY_EVENT_STORE_ENGINE` |
| `server.activityStore.dsn` (when `server.activityStore.engine` is set) | `NB_ACTIVITY_EVENT_POSTGRES_DSN` |
| `server.activityStore.file` | `NB_ACTIVITY_EVENT_SQLITE_FILE` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `server.store.dsn` (when `server.store.engine` is `postgres` or `mysql`) | `NB_STORE_ENGINE_POSTGRES_DSN` or `NB_STORE_ENGINE_MYSQL_DSN` |
| `server.store.file` | `NB_STORE_ENGINE_SQLITE_FILE` |
| `server.activityStore.engine` | `NB_ACTIVITY_EVENT_STORE_ENGINE` |
| `server.activityStore.dsn` (when `server.activityStore.engine` is set) | `NB_ACTIVITY_EVENT_POSTGRES_DSN` |
| `server.activityStore.file` | `NB_ACTIVITY_EVENT_SQLITE_FILE` |
| `server.store.dsn` (when `server.store.engine` is `postgres`) | `NB_STORE_ENGINE_POSTGRES_DSN` |
| `server.store.file` | `NB_STORE_ENGINE_SQLITE_FILE` |
| `server.activityStore.engine` | `NB_ACTIVITY_EVENT_STORE_ENGINE` |
| `server.activityStore.dsn` (when `server.activityStore.engine` is set) | `NB_ACTIVITY_EVENT_POSTGRES_DSN` |
| `server.activityStore.file` | `NB_ACTIVITY_EVENT_SQLITE_FILE` |
| `server.accessLogStore.engine` | `NB_ACCESS_LOG_STORE_ENGINE` |
| `server.accessLogStore.dsn` | `NB_ACCESS_LOG_POSTGRES_DSN` |
| `server.accessLogStore.file` | `NB_ACCESS_LOG_SQLITE_FILE` |

| `server.activityStore.dsn` (when `server.activityStore.engine` is set) | `NB_ACTIVITY_EVENT_POSTGRES_DSN` |
| `server.activityStore.file` | `NB_ACTIVITY_EVENT_SQLITE_FILE` |

A variable set on the container takes effect only when its `config.yaml` field is empty.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A variable set on the container takes effect only when its `config.yaml` field is empty.
A variable set on the container takes effect only when its `config.yaml` field is empty. The activity DSN is the exception: with `server.activityStore.engine: postgres`, the server does not start without `server.activityStore.dsn`. To take it from the environment, leave both fields empty and set `NB_ACTIVITY_EVENT_STORE_ENGINE=postgres` and `NB_ACTIVITY_EVENT_POSTGRES_DSN`.

This branch was successfully deployed

1 active deployment
Preview — d8f7156a Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants