You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(infra): turn a bridge-subnet collision into actionable guidance (#180)
The configurable subnet (network.subnet) gives an affected host the knob, but a
non-expert who hits Docker's cryptic "Pool overlaps with other one on this
address space" won't know to use it. `pithead up`/`apply`/`upgrade` now capture
the compose-up failure and, when it's a subnet overlap, print the exact fix —
set network.subnet to a free /24 (with an example) — instead of a raw Docker
stack trace. Pure, unit-tested explain_subnet_collision helper.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
warn "Docker refused the stack's bridge subnet ($sub): it overlaps a network already on this host."
111
+
warn "Pick a free /24 and set it in ${CONFIG_FILE:-config.json} — e.g. \"network\": { \"subnet\": \"172.30.0.0/24\" } — then re-run '$0 apply' && '$0 up' (see docs/configuration.md, network.subnet)." ;;
112
+
esac
113
+
}
114
+
115
+
# Run `docker compose up` with live output; on failure, explain a bridge-subnet collision (#180) if
116
+
# that's what Docker rejected. Returns compose's own exit code.
117
+
compose_up_checked() {
118
+
local tmp out rc
119
+
tmp="$(mktemp)"
120
+
docker compose up "$@"2>&1| tee "$tmp"
121
+
rc=${PIPESTATUS[0]}
122
+
out="$(cat "$tmp")"; rm -f "$tmp"
123
+
[ "$rc"-ne 0 ] && explain_subnet_collision "$out"
124
+
return"$rc"
125
+
}
126
+
103
127
stack_up() {
104
128
log "Starting stack..."
105
129
warn_missing_data_dirs
106
130
migrate_compose_project
107
131
# Docker Compose automatically picks up COMPOSE_PROFILES from .env
108
-
docker compose up -d
132
+
if! compose_up_checked -d;then
133
+
error "Stack failed to start — see the error above."
134
+
fi
109
135
log "Stack started successfully!"
110
136
announce_dashboard_url
111
137
}
@@ -140,7 +166,9 @@ stack_upgrade() {
140
166
generate_caddyfile
141
167
log "Re-rendered generated config for the current release."
142
168
migrate_compose_project
143
-
docker compose up -d --build
169
+
if! compose_up_checked -d --build;then
170
+
error "Upgrade failed during 'docker compose up' — see the error above."
171
+
fi
144
172
log "Stack upgraded."
145
173
}
146
174
@@ -2035,7 +2063,7 @@ apply() {
2035
2063
:>"$apply_marker"
2036
2064
# Compose recreates only the services whose resolved config changed; --remove-orphans
2037
2065
# drops monerod when a local→remote switch deactivates the local_node profile.
2038
-
if!docker compose up -d --remove-orphans;then
2066
+
if!compose_up_checked -d --remove-orphans;then
2039
2067
warn "Config files were updated but containers were NOT recreated ('docker compose up' failed)."
2040
2068
warn "Fix the cause shown above, then re-run '$0 apply' (it will retry the recreate) — or '$0 up'."
2041
2069
exit 1 # leave $apply_marker in place so the retry re-attempts the recreate
0 commit comments