Skip to content

Commit 9bb3295

Browse files
h4x3rotabclaude
andcommitted
fix(consul-postgres-ha): generate Envoy bootstrap then exec, bypassing version check
Consul 1.19's `consul connect envoy` (without -bootstrap) tries to exec envoy itself and rejects "Envoy version 1.30.x is not supported" — the contrib-v1.30 image we use isn't on its compatibility list. Going back to the original pattern: `consul connect envoy ... -bootstrap > /tmp/envoy-X.json` to just generate the JSON, then `exec envoy -c /tmp/envoy-X.json`. The bootstrap config itself works fine; only the consul-launches-envoy path enforces the version check. Restored the pattern for both the webdemo and postgres sidecar Envoys, with a supervise loop that re-bootstraps and restarts envoy if it ever exits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2a6926c commit 9bb3295

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

consul-postgres-ha/mesh-sidecar/entrypoint.sh

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,34 +208,50 @@ EOF
208208
# Wait for Connect CA to be able to mint leaf certs. Servers don't
209209
# need Envoy to form quorum (Raft RPC rides peer VIPs as plain TCP),
210210
# but workers can't start their sidecars until a server can issue.
211+
# The leaf-cert API is HTTP-only — there is no `consul connect ca
212+
# leaf` CLI subcommand (only get-config / set-config).
211213
log "waiting for connect CA to be ready..."
212-
until consul connect ca leaf -service="${CLUSTER_NAME}" >/dev/null 2>&1; do
214+
until curl -fsS "http://127.0.0.1:8500/v1/agent/connect/ca/leaf/${CLUSTER_NAME}" >/dev/null 2>&1; do
213215
sleep 2
214216
done
215217
log "connect CA ready"
216218

217-
# Webdemo Envoy supervise loop. Webdemo registers itself + a
218-
# SidecarService block with port=21000 from its own entrypoint;
219-
# consul connect envoy waits for that registration to land.
219+
# Webdemo Envoy supervise loop. We use `consul connect envoy
220+
# -bootstrap` to generate the JSON, then exec envoy ourselves; this
221+
# bypasses Consul's Envoy version-compatibility check (Envoy 1.30
222+
# bundled with the sidecar image isn't on Consul 1.19's supported
223+
# list, but the bootstrap config is fine). Webdemo registers its own
224+
# SidecarService block from webdemo/main.go; the bootstrap call
225+
# blocks until that registration is in place.
220226
(
221-
until consul connect envoy \
227+
while true; do
228+
if consul connect envoy \
222229
-sidecar-for="webdemo-${PEER_ID}" \
223230
-admin-bind="127.0.0.1:19000" \
224-
>/dev/null 2>/dev/null; do
225-
echo "[envoy-webdemo] waiting for webdemo sidecar registration..."
231+
-bootstrap \
232+
> /tmp/envoy-webdemo.json 2>/dev/null; then
233+
envoy -c /tmp/envoy-webdemo.json -l info 2>&1
234+
else
235+
echo "[envoy-webdemo] waiting for webdemo sidecar registration..."
236+
fi
226237
sleep 2
227238
done
228239
) 2>&1 | prefix envoy-webdemo &
229240
ENVOYS+=("$!")
230241

231-
# Postgres Envoy supervise loop. The proxy-id is what we registered
232-
# above; consul connect envoy bootstraps Envoy from that registration.
242+
# Postgres Envoy supervise loop, same pattern. Bootstrap from the
243+
# standalone connect-proxy registration above.
233244
(
234-
until consul connect envoy \
245+
while true; do
246+
if consul connect envoy \
235247
-proxy-id="postgres-sidecar-${PEER_ID}" \
236248
-admin-bind="127.0.0.1:19001" \
237-
>/dev/null 2>/dev/null; do
238-
echo "[envoy-postgres] waiting for ca leaf..."
249+
-bootstrap \
250+
> /tmp/envoy-postgres.json 2>/dev/null; then
251+
envoy -c /tmp/envoy-postgres.json -l info 2>&1
252+
else
253+
echo "[envoy-postgres] waiting for ca leaf / proxy registration..."
254+
fi
239255
sleep 2
240256
done
241257
) 2>&1 | prefix envoy-postgres &

0 commit comments

Comments
 (0)