Skip to content

Conversation

@zbitname
Copy link
Collaborator

@zbitname zbitname commented Nov 18, 2025

Summary by CodeRabbit

  • New Features

    • Added two command-line options to customize network ports: WireGuard (UDP, default 51820) and Swarm DB Gossip (UDP/TCP, default 7946).
    • Added a new swarm-init mode option to enable swarm-init at boot.
  • Documentation

    • Help/usage output updated to document the new options and defaults.
  • Diagnostics

    • Runtime debug output now reports the configured ports and mode.

✏️ Tip: You can customize this high-level summary in your review settings.

- Introduced DEFAULT_SWARM_DB_GOSSIP_PORT variable with a default value of 7946.
- Updated usage function to include --swarm_db_gossip_port option.
- Modified parameter parsing to handle the new gossip port argument.
- Enhanced network settings to forward UDP and TCP traffic for the Swarm DB Gossip Port.
- Introduced DEFAULT_WG_PORT and DEFAULT_WG_PORT_RANGE variables for WireGuard configuration.
- Updated usage function to include --wg_port and --wg_port_range options.
- Enhanced parameter parsing to handle WireGuard port and range arguments.
- Modified network settings to forward UDP traffic for the specified WireGuard port and range.
- Deleted DEFAULT_WG_PORT_RANGE variable and its associated logic from the script.
- Updated usage function to remove --wg_port_range option.
- Simplified network settings by eliminating the conditional handling for WireGuard port range.
- Introduced DEFAULT_ROOT_WRITABLE variable to manage root filesystem writability.
- Updated usage function to include --root_writable option.
- Enhanced parameter parsing to handle the new root writable argument.
- Modified kernel command line and image drive settings based on the root writable option.
- Updated logic to create a qcow2 overlay when ROOT_WRITABLE is true, allowing for an immutable base image while enabling writes.
- Added checks to create or use an existing overlay image, improving the management of writable root filesystems.
- Removed the check for existing overlay image and added logic to always create a new qcow2 overlay.
- Simplified the overlay management by ensuring the previous overlay is removed before creation, enhancing the script's reliability.
- Removed unnecessary conditional statement to ensure the qcow2 overlay is always created after the previous one is removed.
- Improved script reliability by streamlining the overlay management process.

NETWORK_SETTINGS+=",hostfwd=udp:0.0.0.0:$WG_PORT-:51820"
NETWORK_SETTINGS+=",hostfwd=udp:0.0.0.0:$SWARM_DB_GOSSIP_PORT-:7946"
NETWORK_SETTINGS+=",hostfwd=tcp:0.0.0.0:$SWARM_DB_GOSSIP_PORT-:7946"
Copy link
Contributor

Choose a reason for hiding this comment

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

erroneous duplication?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Different protos (tcp/udp)


IMAGE_DRIVE=" -drive file=${IMAGE_PATH},if=virtio,format=raw"
if [[ "${ROOT_WRITABLE}" == "true" ]]; then
# Use qcow2 overlay to keep the base image immutable while allowing writes
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that this is not an overlay, but an addition image file.

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

Adds CLI options and defaults for WireGuard and Swarm DB Gossip ports, integrates those ports into QEMU hostfwd rules (UDP 51820, UDP/TCP 7946), and introduces a --swarm-init flag that appends vm_mode=swarm-init to the kernel command line.

Changes

Cohort / File(s) Summary
Port configuration, CLI, and QEMU forwarding
scripts/start_super_protocol.sh
Add DEFAULT_WG_PORT and DEFAULT_SWARM_DB_GOSSIP_PORT; introduce --wg_port and --swarm_db_gossip_port flags and WG_PORT/SWARM_DB_GOSSIP_PORT variables; extend usage/help; print new ports in debug output; add hostfwd rules for UDP 51820 (WireGuard) and UDP/TCP 7946 (Swarm DB Gossip) in QEMU networking setup.
VM mode / kernel cmdline
scripts/start_super_protocol.sh
Add --swarm-init flag and SWARM_INIT variable; append vm_mode=swarm-init to kernel command line when enabled; reflect flag in parameter checks and debug output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped in code to add a gate,
Ports for gossip and a WireGuard state.
A tiny flag to tell the VM’s role,
Forwarded packets keep the network whole.
Cheers — the rabbit bounces, mission complete! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Feature/swarm' is vague and generic, using a branch-naming convention rather than describing the actual changes implemented in the pull request. Replace with a descriptive title that clearly summarizes the main changes, such as 'Add WireGuard and Swarm DB port forwarding support' or 'Implement swarm-init mode and network port configuration'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/swarm

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ea432ef and 31e88e4.

📒 Files selected for processing (1)
  • scripts/start_super_protocol.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/start_super_protocol.sh

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0337a21 and ea432ef.

📒 Files selected for processing (1)
  • scripts/start_super_protocol.sh (6 hunks)
🔇 Additional comments (6)
scripts/start_super_protocol.sh (6)

31-32: LGTM!

The default port values are correct: 51820 is the standard WireGuard port and 7946 is the standard Docker Swarm gossip port.


121-121: LGTM!

Variable initialization follows the established pattern and correctly uses the default values.

Also applies to: 124-124


151-151: LGTM!

Argument parsing is correct and follows the established pattern.

Also applies to: 154-154


785-786: LGTM!

Debug output formatting is consistent with existing debug messages and correctly displays the new port values.


943-943: Clarification: This is NOT a duplicate.

Addressing the past review comment: Line 943 (TCP forwarding) is intentional and necessary. Docker Swarm's gossip protocol requires both UDP and TCP on port 7946 for proper operation—UDP for gossip messaging and TCP for failure detection and state synchronization.


941-943: Verify the IP binding choice for the new port forwards.

The new port forwards use 0.0.0.0 (all interfaces), while HTTP/HTTPS ports use $IP_ADDRESS (lines 935, 938). This difference might be intentional to allow WireGuard VPN and Swarm clustering to listen on all interfaces, but please confirm this is the desired behavior for your security model.

echo " --wg_port <port> WireGuard port (default: ${DEFAULT_WG_PORT})"
echo " --http_port <port> HTTP port (default: no port forward)"
echo " --https_port <port> HTTPS port (default: no port forward)"
echo " --swarm_db_gossip_port <port> Swarm DB Gossip Port"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add default value to help text for consistency.

The --swarm_db_gossip_port option is missing its default value in the help text, unlike other port options (e.g., line 88 for --wg_port).

🔎 Apply this diff to add the default value:
-  echo "  --swarm_db_gossip_port <port> Swarm DB Gossip Port"
+  echo "  --swarm_db_gossip_port <port> Swarm DB Gossip Port (default: ${DEFAULT_SWARM_DB_GOSSIP_PORT})"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo " --swarm_db_gossip_port <port> Swarm DB Gossip Port"
echo " --swarm_db_gossip_port <port> Swarm DB Gossip Port (default: ${DEFAULT_SWARM_DB_GOSSIP_PORT})"
🤖 Prompt for AI Agents
In scripts/start_super_protocol.sh around line 91, the help text for
"--swarm_db_gossip_port" lacks the default value; update the echo to include the
same default-value format used by other port options (e.g., append " (default:
<port>)") so the help output is consistent—set the default port to the same
value used in the script/config for swarm DB gossip.

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.

4 participants