Refactor slow activities from nm-dispatcher script into separate listener service - #680
Refactor slow activities from nm-dispatcher script into separate listener service#680lmagyar wants to merge 6 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe dispatcher now queues selected NetworkManager events. A dedicated s6-overlay listener processes route protection asynchronously. Separate initialization and finish scripts manage route protection during service startup and shutdown. ChangesSubnet protection orchestration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant NetworkManager
participant Dispatcher
participant Queue
participant Listener
participant RouteProtection
NetworkManager->>Dispatcher: NetworkManager action
Dispatcher->>Queue: Enqueue interface and action
Dispatcher-->>NetworkManager: Return after queue write
Queue->>Listener: Deliver queued action
Listener->>RouteProtection: Update subnet routes
RouteProtection-->>Listener: Protection result
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnets`:
- Around line 17-21: Before writing to the listener queue, verify
NM_DISPATCHER_LISTENER_QUEUE exists and is a FIFO (use [ -p
"$NM_DISPATCHER_LISTENER_QUEUE" ]) and wait with a short timeout (e.g., loop up
to a few seconds) for it to appear as a FIFO; if it never becomes a FIFO, log
fatal and exit (same behavior as current error path). Do not create a regular
file by redirecting into a non-existent path; instead fail fast when the FIFO is
absent or wrong type. Use the existing variables DEVICE_IP_IFACE and
NM_DISPATCHER_ACTION for the payload and preserve the current exit behavior that
writes to /run/s6-linux-init-container-results/exitcode and calls halt if the
check/write fails.
In `@tailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/run`:
- Around line 22-25: The script must fail fast if mkfifo fails or the path is
not a FIFO: before executing "exec 4<>\"${NM_DISPATCHER_LISTENER_QUEUE}\"",
attempt to create the FIFO with mkfifo and then validate the path is a FIFO
using a POSIX test (e.g., [ -p "$NM_DISPATCHER_LISTENER_QUEUE" ]); if mkfifo
fails and the path is absent or exists but is not a FIFO, write an error and
exit non‑zero so the listener doesn't proceed to "exec 4<>" on a regular file.
Update the run script around the mkfifo/exec 4<> sequence to perform this
validation and early exit when the queue is not a proper FIFO.
🪄 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: 44d4ff22-5e51-49a1-9aa9-a5143aac6027
📒 Files selected for processing (19)
tailscale/rootfs/etc/NetworkManager/dispatcher.d/protect-subnetstailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/dependencies.d/local-networktailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/downtailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/finishtailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/runtailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/typetailscale/rootfs/etc/s6-overlay/s6-rc.d/init-protect-subnets/uptailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/dependencies.d/init-protect-subnetstailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/finishtailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/runtailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher-listener/typetailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/dependencies.d/nm-dispatcher-listenertailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/finishtailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/runtailscale/rootfs/etc/s6-overlay/s6-rc.d/nm-dispatcher/typetailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/init-protect-subnetstailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatchertailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/contents.d/nm-dispatcher-listenertailscale/rootfs/etc/s6-overlay/s6-rc.d/protect-subnets/type
|
Looks quite neat, and I've tested it on my end, Tailscale no longer blocks Supervisor restart with this change (even with ✔️ LGTM! |
|
Thank you for the feedback! |
Proposed Changes
There is a plain linux pipe between the 2 services, each nm-dispatcher action is 1 line in it, then all the slow thing happen in the listener service sequentially - as currently, but returning to nm-dispatcher quickly.
Related Issues
fixes #678
closes #679
Summary by CodeRabbit