Commit 57705ad
fix(consul-postgres-ha): role-watcher + set-e isolation in supervise loops
Two related fixes:
1. **Role watcher**: service-resolver subset filters in Connect EDS
apply to the SIDECAR registration's Tags, not to the parent
service's tags (Patroni's stage4 instance tags don't propagate
to the postgres-sidecar-proxy registration). Added a polling
loop in entrypoint.sh that watches Patroni's REST API at
`127.0.0.1:8008/` and re-PUTs the postgres-sidecar registration
with `Tags=["master"]` or `["replica"]` whenever Patroni's role
changes. Initial registration starts with Tags=[]; the watcher
fills it in within ~5s of Patroni REST coming up.
2. **Supervise-loop isolation**: each Envoy + the role-watcher run
in a `(... &) | prefix` subshell. They inherited the outer
entrypoint's `set -euo pipefail`, so a single failed `curl`
(Patroni REST not yet up) or an Envoy crash (no Consul leader
yet → bootstrap config can't be fetched) propagated as subshell
exit → `wait -n` returned → container teardown cascade. Added
`set +eo pipefail` at the start of each supervise subshell so
the while-true retry loop survives expected transient failures.
This is what was missing for the first end-to-end Patroni-via-Connect
to fire: without role tags on the sidecar, postgres-master EDS
returns empty; without supervise-loop isolation, the first Envoy
crash kills the container.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9bb3295 commit 57705ad
1 file changed
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
| 232 | + | |
227 | 233 | | |
228 | 234 | | |
229 | 235 | | |
| |||
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
| 251 | + | |
245 | 252 | | |
246 | 253 | | |
247 | 254 | | |
| |||
256 | 263 | | |
257 | 264 | | |
258 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
259 | 303 | | |
260 | 304 | | |
261 | 305 | | |
| |||
0 commit comments