Skip to content

Commit 0007a17

Browse files
committed
Clean up HA cluster shell lint
1 parent 82c1c2d commit 0007a17

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

consul-postgres-ha/cluster-example/rollout.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ wait_for_quorum_healthy() {
9797
snapshot_consul() {
9898
local label="$1"
9999
local snap_dir="snapshots"
100+
local f
100101
mkdir -p "$snap_dir"
101-
local f="$snap_dir/${label}-$(date +%Y%m%d-%H%M%S).snap"
102+
f="$snap_dir/${label}-$(date +%Y%m%d-%H%M%S).snap"
102103
if curl -sf -X PUT "${CONSUL_BASE}/v1/snapshot" -o "$f"; then
103104
echo "snapshot saved: $f"
104105
else

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
524523
shutdown() {
525524
log "received signal, terminating children"
526525
for c in "${CHILDREN[@]}"; do

consul-postgres-ha/patroni/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ${CONSUL_TOKEN_YAML}
8484
# and re-PUTs the parent registration with tags ["master"] or
8585
# ["replica"] so service-resolver subset filters match. We do this
8686
# because Patroni deregisters the service every loop iteration while
87-
# `role=uninitialized` (the entire pre-bootstrap window on a
87+
# role=uninitialized (the entire pre-bootstrap window on a
8888
# replica), which wipes the registration our connect-proxy depends
8989
# on for proxycfg state. With register_service:false Patroni stays
9090
# out of the agent's service catalog and just uses Consul as DCS.

0 commit comments

Comments
 (0)