@@ -289,7 +289,6 @@ if [ "$ROLE" = "worker" ]; then
289289 ADMISSION_IDENTITY=$( jq -r ' .admission_identity // empty' <<< " $BACKEND" )
290290 BASE_ID=$(( BACKEND_IDX + 1 ))
291291 ADMIN_PORT=$(( 19000 + BACKEND_IDX))
292- SIDECAR_ID=" ${PARENT} -sidecar-${PEER_ID} "
293292 SPEC_FILE=" /tmp/sidecar-${PARENT} .json"
294293 ENVOY_BOOT=" /tmp/envoy-${PARENT} .json"
295294 TOKEN_FILE=" /run/instance/consul-token-${PARENT} "
@@ -299,7 +298,7 @@ if [ "$ROLE" = "worker" ]; then
299298 [ -n " $ADMISSION_IDENTITY " ] || { log " backend ${PARENT} missing admission_identity" ; exit 1; }
300299 BROKER_URLS=$( echo " $COORDINATOR_VIPS " | tr ' ,' ' \n' | awk ' NF { printf "%shttp://127.50.0.%s:8787", sep, $1; sep="," }' )
301300 log " requesting admission token for ${PARENT} (${ADMISSION_IDENTITY} )"
302- PEER_ID= " $PEER_ID " /usr/local/bin/admission-client \
301+ /usr/local/bin/admission-client \
303302 -identity " $ADMISSION_IDENTITY " \
304303 -broker-urls " $BROKER_URLS " \
305304 -token-file " $TOKEN_FILE " \
@@ -352,10 +351,9 @@ if [ "$ROLE" = "worker" ]; then
352351 # alongside the new inline SidecarService, `consul connect envoy
353352 # -sidecar-for` sees two matches and refuses to render. Deregister
354353 # known stale IDs idempotently before we PUT the new spec.
355- for stale_id in " ${PARENT} -sidecar-${PEER_ID} " ; do
356- curl -fsS " ${CURL_TOKEN_ARGS[@]} " -X PUT " http://127.0.0.1:8500/v1/agent/service/deregister/${stale_id} " \
357- > /dev/null 2>&1 || true
358- done
354+ STALE_SIDECAR_ID=" ${PARENT} -sidecar-${PEER_ID} "
355+ curl -fsS " ${CURL_TOKEN_ARGS[@]} " -X PUT " http://127.0.0.1:8500/v1/agent/service/deregister/${STALE_SIDECAR_ID} " \
356+ > /dev/null 2>&1 || true
359357 jq -n \
360358 --arg name " $PARENT " \
361359 --arg id " $PARENT_ID " \
@@ -521,6 +519,7 @@ CHILDREN=("$MESH" "$CONSUL")
521519[ -n " $ADMISSION_BROKER_PID " ] && CHILDREN+=(" $ADMISSION_BROKER_PID " )
522520[ ${# ENVOYS[@]} -gt 0 ] && CHILDREN+=(" ${ENVOYS[@]} " )
523521
522+ # shellcheck disable=SC2317 # Invoked indirectly by the TERM/INT trap.
524523shutdown () {
525524 log " received signal, terminating children"
526525 for c in " ${CHILDREN[@]} " ; do
0 commit comments