Skip to content

[fix] Decoupled ZeroTier network name from VPN name #1426#1429

Open
Jaydeng75 wants to merge 1 commit into
openwisp:masterfrom
Jaydeng75:issues/1426-zerotier-vpn-name-coupling
Open

[fix] Decoupled ZeroTier network name from VPN name #1426#1429
Jaydeng75 wants to merge 1 commit into
openwisp:masterfrom
Jaydeng75:issues/1426-zerotier-vpn-name-coupling

Conversation

@Jaydeng75

Copy link
Copy Markdown

Preserve the ZeroTier network name returned by the API and use it
for configuration context variables. VPN name changes no longer
alter the machine-facing ZeroTier network name.

Closes #1426

Checklist

  • I have read the OpenWISP Contributing Guidelines and OpenWISP Anti AI Spam Policy.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • [N/A] I have updated the documentation.

Reference to Existing Issue

Closes #1426.

Description of Changes

This change decouples the human-facing Vpn.name field from the
machine-facing ZeroTier network name used in configuration context
variables.

The changes:

  • Preserve the ZeroTier network name returned by the API in the stored
    VPN configuration instead of treating name as a redundant response
    field.
  • Use the stored ZeroTier network name for the network_name
    configuration context variable, with Vpn.name as a fallback for
    backward compatibility with existing VPN configurations.
  • Set the initial ZeroTier network name from Vpn.name only when the
    VPN is created, preventing subsequent administrative renames from
    being propagated to the ZeroTier controller.
  • Add a regression test verifying that renaming Vpn.name does not
    change the machine-facing ZeroTier network name used in configuration
    context variables.

This prevents administrative VPN renames from unnecessarily changing
client configuration context and invalidating configuration caches.

Screenshot

N/A — this change does not affect the user interface.

Preserve the ZeroTier network name returned by the API and use it
for configuration context variables. VPN name changes no longer
alter the machine-facing ZeroTier network name.

Closes openwisp#1426

Signed-off-by: Jayden Jeswin Raj <user.josephms@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change decouples the ZeroTier network name from the human-facing VPN name. ZerotierService._get_repsonse no longer strips the "name" field from API responses. AbstractVpn.save() now sets config["name"] only when the VPN is created, and get_vpn_server_context() derives network_name from the stored ZeroTier config, falling back to self.name only if absent. A test verifies the network name stays stable after renaming the VPN.

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

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant AbstractVpn
  participant ZerotierConfig
  participant Template

  Admin->>AbstractVpn: rename VPN (change name)
  AbstractVpn->>AbstractVpn: save(created=False)
  AbstractVpn->>ZerotierConfig: config["name"] not reassigned
  Template->>AbstractVpn: get_vpn_server_context()
  AbstractVpn->>ZerotierConfig: read stored zerotier config name
  ZerotierConfig-->>Template: network_name unchanged
Loading

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
General Rules ❌ Error The linked issue is labeled bug, but GitHub shows it assigned to project '26.06 Release', not one of the two required boards. Move the issue to OpenWISP Contributor's Board or OpenWISP Priorities for next releases, or document maintainer validation if already done.
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the ZeroTier name decoupling fix and matches the PR changes.
Description check ✅ Passed The description follows the template and includes the checklist, issue reference, change summary, and screenshot note.
Linked Issues check ✅ Passed The changes address #1426 by preserving the ZeroTier network name and stopping VPN renames from overriding it.
Out of Scope Changes check ✅ Passed The diff stays focused on the ZeroTier name handling fix and the supporting regression test.
Bug Fixes ✅ Passed Root cause is fixed: ZeroTier name is preserved in stored config and used for context, and the regression test renames the VPN and verifies network_name stays stable.
Features ✅ Passed Backend bug fix, not a feature request; a regression test was added and there’s no UI impact, so the feature-only docs/screenshot checklist doesn’t apply.
Changes ✅ Passed PASS: Added a regression test, no UI change so screenshots aren’t needed, and the ZeroTier rename behavior keeps a VPN-name fallback for compatibility; no docs were explicitly outdated.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 98.547%Jaydeng75:issues/1426-zerotier-vpn-name-coupling into openwisp:master. No base build found for openwisp:master.

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.

[bug] ZeroTier VPN backend couples human-facing Vpn.name with machine configuration

2 participants