feat(one-click): support cubevs CIDR via env var with conflict detection#451
Conversation
|
Claude finished @fslongjin's task in 2m 19s —— View job Code Review: feat(one-click): support cubevs CIDR via env var with conflict detection
SummaryThis PR introduces three major changes:
I've reviewed all changed files. Overall the code is well-structured with good security consciousness (format validation before bypass, symlink guard, [A] common.sh — Network helper functions
[B] install.sh — CIDR persistence and patchingCIDR preflight call (L446–450): ✅ Clean integration. Validates before Symlink guard (L579–581): ✅ Important defense — refuses to patch a symlink target to prevent TOCTOU/symlink-follow attacks via sed delimiter choice (L586): ✅ Using Persistence after patch (L598–607): ✅ Defense-in-depth — env file is only written after 🟡 Redundant inner check on L598: The block is already inside [C] systemd ExecStart fixes✅ All 🔴 If the ExecStop scripts also use shebangs, systemd 255's [D] upsert_env_kv fix✅ The temp-file-in-same-directory pattern ( [E] Documentation✅ All four documentation files ( ✅ ✅ The DNS deadlock root cause analysis doc is thorough and well-structured. [F] Minor observations
VerdictSolid implementation. The CIDR validation is thorough, security-conscious, and user-friendly. The systemd fix addresses a real production issue on OpenCloudOS 9.4. Two items worth addressing before merging: |
Allow users to specify CUBE_SANDBOX_NETWORK_CIDR at install time to avoid conflicts with existing host network subnets. Key changes: - New env var CUBE_SANDBOX_NETWORK_CIDR (IPv4 CIDR, mask /8-/30) - New helpers: ip_to_int, ip_int_to_dot, check_cidr_preflight, _check_cidr_conflict in lib/common.sh - Preflight validation in install.sh: format check, network alignment, host interface/route overlap detection with fail-fast - Config patching: sed with '|' delimiter to handle '/' in CIDR values - Symlink rejection guard for sed -i safety - Bypass flag: CUBE_SANDBOX_NETWORK_CIDR_SKIP_CONFLICT_CHECK - Persistence to .one-click.env after successful config patch - Fixed upsert_env_kv atomicity: same-directory temp file docs: add CIDR env var entries to env.example and configuration reference tables in self-build-deploy.md and multi-node-deploy.md fix(systemd): use explicit /usr/bin/bash for ExecStart OpenCloudOS 9.4 systemd 255 uses systemd-executor which does not parse script shebangs, causing 203/EXEC errors. Prefix all ExecStart/ExecStartPre/ExecStartPost with /usr/bin/bash. Signed-off-by: jinlong <jinlong@tencent.com>
faac949 to
137b65a
Compare
|
Claude finished @fslongjin's task in 1m 22s —— View job Code Review: feat(one-click): support cubevs CIDR via env var with conflict detectionReviewing PR #451... SummaryThis PR introduces three changes:
I've reviewed all 17 changed files. The code is well-structured with thoughtful security considerations. Below are my findings. [A]
|
| File | ExecStop |
|---|---|
cube-sandbox-coredns.service |
/usr/local/services/cubetoolbox/scripts/systemd/coredns-stop.sh |
cube-sandbox-cubelet.service |
/usr/local/services/cubetoolbox/scripts/systemd/cubelet-stop.sh |
cube-sandbox-cubemaster.service |
(no ExecStop defined, but cube-sandbox-cubelet.service has one) |
cube-sandbox-mysql.service |
/usr/local/services/cubetoolbox/scripts/systemd/mysql-stop.sh |
cube-sandbox-redis.service |
/usr/local/services/cubetoolbox/scripts/systemd/redis-stop.sh |
cube-sandbox-webui.service |
/usr/local/services/cubetoolbox/scripts/systemd/webui-stop.sh |
cube-sandbox-cube-proxy.service |
/usr/local/services/cubetoolbox/scripts/systemd/cube-proxy-stop.sh |
cube-sandbox-dns.service |
/usr/local/services/cubetoolbox/scripts/systemd/dns-host-route-down.sh |
If the stop scripts use shebangs (they likely do, following the same pattern as start scripts), systemd 255's systemd-executor will fail with 203/EXEC on stop as well. While the stop path is less critical (no deadlock risk), stop operations will silently fail on OpenCloudOS 9.4. Recommend prefixing all ExecStop paths with /usr/bin/bash for consistency. Fix all ExecStop paths →
[D] upsert_env_kv fix
✅ Using mktemp "${env_file}.XXXXXX" (same-directory temp file) is the correct fix for cross-filesystem atomic rename. A temp file in /tmp (tmpfs) could not atomically replace a target on an ext4/x4 filesystem. Good defensive fix.
[E] Documentation
✅ env.example (L79–85): Well-documented entries for both CUBE_SANDBOX_NETWORK_CIDR and CUBE_SANDBOX_NETWORK_CIDR_SKIP_CONFLICT_CHECK with mask range constraint and clear comments.
✅ All four docs files (self-build-deploy.md, multi-node-deploy.md, zh versions) include the CIDR env var entries.
[F] Minor observations
-
🟡
check_cidr_preflightis tested withCUBE_SANDBOX_NETWORK_CIDR=set but call at install.sh L448 passes"${CUBE_SANDBOX_NETWORK_CIDR}"(with the:-}default at L446). The function itself also checksif [[ -z "${cidr}" ]]; then return 0at L521. When the env var is empty,check_cidr_preflight ""is called, which returns immediately — correct behavior, but slightly redundant. Consider guarding the call with[[ -n ... ]]instead of relying on the function-level check, for consistency with the outer guard pattern used elsewhere. -
🟡 Line 459
|| true: As noted in [A], this is misleading in a process substitution context. Recommend removing it for clarity.
Verdict
Solid implementation. The CIDR validation is thorough, security-conscious, and user-friendly. The systemd fix addresses a real production issue. Two items worth addressing before merging:
- 🔴 Prefix
ExecStoppaths with/usr/bin/bashin all systemd service files for OpenCloudOS 9.4 compatibility - 🟡 Remove the redundant inner guard in
install.shat L598
— Branch:jinlong-feat-cubevs-cidr-env-var
The same systemd-executor 203/EXEC issue that affected ExecStart also affects ExecStop. Prefix all 7 ExecStop paths with /usr/bin/bash. Signed-off-by: jinlong <jinlong@tencent.com>
|
Claude finished @fslongjin's task in 1m 12s —— View job Code Review: feat(one-click): support cubevs CIDR via env var with conflict detectionProgress Update
SummaryThis PR introduces three changes:
The latest commit ( I've reviewed all 17 changed files. The code is well-structured with thoughtful security considerations. Below are my findings. [A]
|
| File | Before | After |
|---|---|---|
cube-sandbox-coredns.service |
ExecStop=...coredns-stop.sh |
ExecStop=/usr/bin/bash ...coredns-stop.sh |
cube-sandbox-cube-proxy.service |
ExecStop=...cube-proxy-stop.sh |
ExecStop=/usr/bin/bash ...cube-proxy-stop.sh |
cube-sandbox-cubelet.service |
ExecStop=...cubelet-stop.sh |
ExecStop=/usr/bin/bash ...cubelet-stop.sh |
cube-sandbox-dns.service |
ExecStop=...dns-host-route-down.sh |
ExecStop=/usr/bin/bash ...dns-host-route-down.sh |
cube-sandbox-mysql.service |
ExecStop=...mysql-stop.sh |
ExecStop=/usr/bin/bash ...mysql-stop.sh |
cube-sandbox-redis.service |
ExecStop=...redis-stop.sh |
ExecStop=/usr/bin/bash ...redis-stop.sh |
cube-sandbox-webui.service |
ExecStop=...webui-stop.sh |
ExecStop=/usr/bin/bash ...webui-stop.sh |
All 7 ExecStop paths are now correctly prefixed. This ensures systemd 255 compatibility on OpenCloudOS 9.4 for both start and stop paths.
[D] upsert_env_kv fix
✅ Using mktemp "${env_file}.XXXXXX" (same-directory temp file) is the correct fix for cross-filesystem atomic rename. A temp file in /tmp (tmpfs) could not atomically replace a target on an ext4/xfs filesystem. Good defensive fix.
[E] Documentation
✅ env.example (L79–85): Well-documented entries for both CUBE_SANDBOX_NETWORK_CIDR and CUBE_SANDBOX_NETWORK_CIDR_SKIP_CONFLICT_CHECK with mask range constraint and clear comments.
✅ All four docs files (self-build-deploy.md, multi-node-deploy.md, zh versions) include the CIDR env var entries.
[F] Minor observations (unchanged from prior review)
- 🟡 Line 459
|| true: In a process substitution context, the|| trueis not needed and could be misleading —ipfailure here is already guarded byrequire_cmd ipat L417. Consider removing for clarity. - 🟡 Redundant inner guard at L598: As noted in section [B], this could be simplified.
Verdict
Solid implementation. The CIDR validation is thorough, security-conscious, and user-friendly. The ExecStop issue from the previous review has been fully resolved in commit 3d70d53.
Remaining minor suggestions (optional, 🟡 level):
- Remove the redundant inner guard at
install.shL598 - Remove the misleading
|| trueatcommon.shL459

Allow users to specify CUBE_SANDBOX_NETWORK_CIDR at install time to avoid conflicts with existing host network subnets.
Key changes:
docs: add CIDR env var entries to env.example and configuration reference tables in self-build-deploy.md and multi-node-deploy.md
fix(systemd): use explicit /usr/bin/bash for ExecStart
OpenCloudOS 9.4 systemd 255 uses systemd-executor which does not parse script shebangs, causing 203/EXEC errors. Prefix all ExecStart/ExecStartPre/ExecStartPost with /usr/bin/bash.