Skip to content

Add HA guide for self-hosted Enterprise#812

Merged
SunsetDrifter merged 8 commits into
mainfrom
add-ha-docs
Jun 25, 2026
Merged

Add HA guide for self-hosted Enterprise#812
SunsetDrifter merged 8 commits into
mainfrom
add-ha-docs

Conversation

@bcmmbaga

@bcmmbaga bcmmbaga commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added support for rendering interactive diagrams in code blocks, including zoomable viewing and better theme handling.
  • Documentation

    • Added a new high-availability guide for self-hosted deployments, covering setup, migration steps, scaling, upgrades, and troubleshooting.
    • Updated related scaling documentation links for easier navigation.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new React Mermaid component (src/components/Mermaid.jsx) with lazy mermaid loading, theme-aware SVG rendering, dark/light mode tracking via MutationObserver, and a portal-based zoom lightbox. Wires it into Code.jsx's Pre renderer for language === 'mermaid' blocks. Adds the mermaid ^11.15.0 npm dependency. Introduces a new 699-line MDX guide for active-active HA deployment of NetBird Enterprise Management and Signal, with a cross-link added to the existing scaling overview.

Changes

Mermaid Diagram Renderer

Layer / File(s) Summary
Mermaid component: lazy loading, rendering, and theme tracking
package.json, src/components/Mermaid.jsx
Adds mermaid ^11.15.0 dependency, module-level cached dynamic import, isDarkMode() via document.documentElement class, async SVG render effect with run-counter and cancellation guards, MutationObserver to re-render on theme change, and error/placeholder early returns.
Mermaid component: zoom lightbox and Code.jsx wiring
src/components/Mermaid.jsx, src/components/Code.jsx
Adds CloseIcon SVG, close() with 200ms closing state, Escape keydown handler, zoomSvg max-width strip, portal-based overlay lightbox with mouse/keyboard activation, and Pre special-case in Code.jsx routing language === 'mermaid' blocks to <Mermaid>.

High Availability Documentation

Layer / File(s) Summary
HA guide: introduction, architecture, and prerequisites
src/pages/selfhosted/maintenance/scaling/high-availability.mdx
New HA page with Enterprise license scope, migration framing, pre-migration checklist, target architecture diagram (Management/Signal/Relay pools sharing Postgres/Redis/NATS), active-active Signal routing via NATS, and instance-count/FQDN prerequisites.
HA guide: PostgreSQL, Redis, and NATS setup
src/pages/selfhosted/maintenance/scaling/high-availability.mdx
Steps 1–3: PostgreSQL as opaque DSN with encryption key preservation; Redis as single standalone-compatible endpoint with cluster/Sentinel prohibition; 3-node NATS cluster with JetStream traffic-events stream and verification commands.
HA guide: load balancer, Relay, Signal, and Management deployment
src/pages/selfhosted/maintenance/scaling/high-availability.mdx
Steps 4–7: L7 LB frontend specs (HTTP/2+gRPC, WebSocket, health checks), Relay pool (shared NB_AUTH_SECRET, embedded STUN), Enterprise Signal HA image (NATS_ENDPOINTS, SINGLE_NODE_MODE=false), and Management config.yaml with ha.enabled, natsEndpoints, redisAddr, and ordered replica rollout.
HA guide: verification, operations, troubleshooting, and cross-link
src/pages/selfhosted/maintenance/scaling/high-availability.mdx, src/pages/selfhosted/maintenance/scaling/scaling-your-self-hosted-deployment.mdx
Step 8 failure scenarios, rolling upgrade/scaling procedures, secret rotation rules (encryptionKey rotation prohibited), troubleshooting for key mismatches, PKCE failures, Signal misconfiguration, NATS quorum loss, and relay token mismatches. Adds cross-link in the existing scaling overview.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • SunsetDrifter
  • braginini

Poem

🐇 A diagram blooms in the dark of the night,
With NATS and with Redis and Postgres just right—
The Mermaid now renders, the zoom lights the way,
And HA stands tall through the turbulent day.
This rabbit hops proud through the code review queue! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a high-availability guide for self-hosted Enterprise.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-ha-docs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/components/Mermaid.jsx

Oops! Something went wrong! :(

ESLint: 9.39.4

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'configs' -> object with constructor 'Object'
| property 'flat' -> object with constructor 'Object'
| ...
| property 'plugins' -> object with constructor 'Object'
--- property 'react' closes the circle
Referenced from:
at JSON.stringify ()
at file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:308:45
at Array.map ()
at ConfigValidator.formatErrors (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:299:23)
at ConfigValidator.validateConfigSchema (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:330:84)
at ConfigArrayFactory._normalizeConfigData (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:676:19)
at ConfigArrayFactory._loadConfigData (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:641:21)
at ConfigArrayFactory._loadExtendedShareableConfig (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:946:21)
at ConfigArrayFactory._loadExtends (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:814:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:752:25)

src/pages/selfhosted/maintenance/scaling/high-availability.mdx

Oops! Something went wrong! :(

ESLint: 9.39.4

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'configs' -> object with constructor 'Object'
| property 'flat' -> object with constructor 'Object'
| ...
| property 'plugins' -> object with constructor 'Object'
--- property 'react' closes the circle
Referenced from:
at JSON.stringify ()
at file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:308:45
at Array.map ()
at ConfigValidator.formatErrors (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:299:23)
at ConfigValidator.validateConfigSchema (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:330:84)
at ConfigArrayFactory._normalizeConfigData (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:676:19)
at ConfigArrayFactory._loadConfigData (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:641:21)
at ConfigArrayFactory._loadExtendedShareableConfig (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:946:21)
at ConfigArrayFactory._loadExtends (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:814:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (file:///node_modules/.pnpm/@eslint+eslintrc@3.3.5/node_modules/@eslint/eslintrc/lib/config-array-factory.js:752:25)


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

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/pages/selfhosted/maintenance/scaling/scaling-your-self-hosted-deployment.mdx (1)

93-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a direct “High Availability” See Also link here.

This page is the natural entry point for scaling docs; adding the new HA guide link alongside Quickstart improves discoverability.

Suggested diff
 ## See Also
 
 - [Configuration Files Reference](/selfhosted/maintenance/configuration-files) - Full config.yaml documentation
+- [High Availability](/selfhosted/maintenance/scaling/high-availability) - Active-active HA deployment for Management and Signal (Enterprise)
 - [Self-hosting Quickstart](/selfhosted/selfhosted-quickstart) - Initial deployment guide
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/pages/selfhosted/maintenance/scaling/scaling-your-self-hosted-deployment.mdx`
around lines 93 - 97, The See Also section in
scaling-your-self-hosted-deployment.mdx should include a direct High
Availability link to improve discoverability from the scaling entry point.
Update the existing See Also list alongside the current Configuration Files
Reference and Self-hosted Quickstart links to add the new HA guide using the
same markdown style, so readers can navigate from this page to the
availability-focused documentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Mermaid.jsx`:
- Around line 51-74: The Mermaid render flow in render() can apply stale results
when overlapping async mermaid.render() calls resolve out of order, and the
captured svg check can also be stale. Add a per-render token/version inside
Mermaid.jsx so each render invocation can verify it is still the latest before
calling setSvg or setError, and keep the early-return guard tied to the current
token rather than the effect-captured svg value. Also apply the same token check
in the cleanup/update path around the existing cancelled logic so older renders
never overwrite newer theme output.
- Around line 59-62: The Mermaid initialization in Mermaid.jsx is using an
unsafe security level for content that is injected into the DOM via
dangerouslySetInnerHTML in both the main and zoom render paths. Update the
Mermaid.initialize call to use a safer securityLevel such as strict, or add SVG
sanitization before rendering the output, and make sure the change applies to
the Mermaid component’s render flow consistently.

In `@src/components/NavigationDocs.jsx`:
- Around line 577-580: The new High Availability navigation item was added in
NavigationDocs but is missing from NavigationAPI, so the two nav definitions are
out of sync. Add the same High Availability entry with the matching href in
NavigationAPI alongside the existing maintenance/scaling items, using the
relevant navigation array or object structure already used there.

---

Nitpick comments:
In
`@src/pages/selfhosted/maintenance/scaling/scaling-your-self-hosted-deployment.mdx`:
- Around line 93-97: The See Also section in
scaling-your-self-hosted-deployment.mdx should include a direct High
Availability link to improve discoverability from the scaling entry point.
Update the existing See Also list alongside the current Configuration Files
Reference and Self-hosted Quickstart links to add the new HA guide using the
same markdown style, so readers can navigate from this page to the
availability-focused documentation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aad4af2f-84bf-401d-8ad1-2716f93d6e3c

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4aa80 and 52757ca.

📒 Files selected for processing (6)
  • package.json
  • src/components/Code.jsx
  • src/components/Mermaid.jsx
  • src/components/NavigationDocs.jsx
  • src/pages/selfhosted/maintenance/scaling/high-availability.mdx
  • src/pages/selfhosted/maintenance/scaling/scaling-your-self-hosted-deployment.mdx

Comment thread src/components/Mermaid.jsx
Comment thread src/components/Mermaid.jsx
Comment thread src/components/NavigationDocs.jsx Outdated

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/Mermaid.jsx (1)

47-48: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Move focus into the zoom dialog when it opens.

The portal is marked aria-modal="true", but focus remains on the trigger/background. Focus the close button on open and restore prior focus on cleanup.

♿ Proposed focus management
   let [svg, setSvg] = useState('')
   let [error, setError] = useState(null)
   let [zoomed, setZoomed] = useState(false)
   let [closing, setClosing] = useState(false)
+  let closeButtonRef = useRef(null)
@@
   useEffect(() => {
     if (!zoomed) return
+    let previouslyFocused = document.activeElement
+    closeButtonRef.current?.focus()
     let onKey = (e) => {
       if (e.key === 'Escape') close()
     }
     document.addEventListener('keydown', onKey)
-    return () => document.removeEventListener('keydown', onKey)
+    return () => {
+      document.removeEventListener('keydown', onKey)
+      if (previouslyFocused instanceof HTMLElement) previouslyFocused.focus()
+    }
   }, [zoomed, close])
@@
             <button
               className="image-zoom-close"
+              ref={closeButtonRef}
               onClick={close}
               aria-label="Close zoomed diagram"
             >

Also applies to: 107-114, 159-165

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Mermaid.jsx` around lines 47 - 48, The zoom dialog in Mermaid
currently opens without moving keyboard focus into the modal, leaving focus on
the trigger/background. Update the focus management in the dialog/portal logic
around the existing open/close state in Mermaid.jsx (including the close-button
setup and cleanup paths) so that opening the zoom dialog focuses the close
button, and closing it restores the previously focused element. Apply the same
pattern wherever the zoom dialog is mounted or toggled so the aria-modal
behavior matches actual focus behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/components/Mermaid.jsx`:
- Around line 47-48: The zoom dialog in Mermaid currently opens without moving
keyboard focus into the modal, leaving focus on the trigger/background. Update
the focus management in the dialog/portal logic around the existing open/close
state in Mermaid.jsx (including the close-button setup and cleanup paths) so
that opening the zoom dialog focuses the close button, and closing it restores
the previously focused element. Apply the same pattern wherever the zoom dialog
is mounted or toggled so the aria-modal behavior matches actual focus behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7a552819-b0a9-4989-9264-6b2465050d4e

📥 Commits

Reviewing files that changed from the base of the PR and between 52757ca and 80bdabe.

📒 Files selected for processing (2)
  • src/components/Mermaid.jsx
  • src/pages/selfhosted/maintenance/scaling/high-availability.mdx
✅ Files skipped from review due to trivial changes (1)
  • src/pages/selfhosted/maintenance/scaling/high-availability.mdx

@SunsetDrifter SunsetDrifter merged commit ffb72cf into main Jun 25, 2026
3 checks passed
@SunsetDrifter SunsetDrifter deleted the add-ha-docs branch June 25, 2026 12:53
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