Skip to content

Commit 334880e

Browse files
h4x3rotabclaude
andcommitted
fix(consul-postgres-ha): deregister legacy Pattern B proxy IDs at sidecar startup
Survives an in-place upgrade from the previous Pattern B shape (`Kind: connect-proxy` with ID `${parent}-sidecar-${peer}`). `/consul/data` is a persistent volume, so the stale registration survives container restarts; if it lingers alongside the new inline-`SidecarService` shape, `consul connect envoy -sidecar-for` sees two matches and refuses to render. Deregister the known legacy IDs idempotently before each PUT. Safe to remove this block in a future release once no live cluster predates the inline-SidecarService landing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ddb2fa2 commit 334880e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,18 @@ if [ "$ROLE" = "worker" ]; then
279279
TAGS_JSON='[]'
280280
fi
281281

282+
# Defensive cleanup: a prior boot may have used different IDs for
283+
# the same logical proxy (e.g. an earlier release of this image
284+
# registered Pattern B as `Kind: connect-proxy` with ID
285+
# `${parent}-sidecar-${peer}`). Consul-data is a persistent volume
286+
# so the stale entries survive container restarts; if they linger
287+
# alongside the new inline SidecarService, `consul connect envoy
288+
# -sidecar-for` sees two matches and refuses to render. Deregister
289+
# known stale IDs idempotently before we PUT the new spec.
290+
for stale_id in "${PARENT}-sidecar-${PEER_ID}"; do
291+
curl -fsS -X PUT "http://127.0.0.1:8500/v1/agent/service/deregister/${stale_id}" \
292+
>/dev/null 2>&1 || true
293+
done
282294
jq -n \
283295
--arg name "$PARENT" \
284296
--arg id "$PARENT_ID" \

0 commit comments

Comments
 (0)