Commit ace25a4
Prevent unnecessary RabbitMQ rolling restarts during scaling and cert rotation
Three changes to align with the upstream rabbitmq-cluster-operator and
prevent quorum queue corruption caused by unnecessary rolling restarts:
1. Remove TLS secret data and replica count from config hash
Stop hashing TLS secret content (tlsSecretData, caSecretData) and
the replica count into the pod-template annotation. The secret names
are still hashed so that switching to a different cert triggers a
restart, but content changes (cert-manager re-issuance, CA chain
updates, rotation) no longer cause rolling restarts. TLS certificates
are mounted via projected volumes that kubelet updates in-place, and
RabbitMQ 4.x reloads them from disk automatically.
During initial deployment the playbook scales RabbitMQ from 1 to 3
replicas, which adds new DNS SANs to the Certificate CR and triggers
cert-manager to re-issue. When secret data was hashed, this caused a
rolling restart before quorum queue replicas had synced, leading to
Raft log divergence and a permanent crash loop (ra_server assertion
"PLIdx < LastApplied").
2. Make PreStop hook replica-count-independent
The PreStop command previously varied based on spec.replicas (skipping
quorum checks for single-replica clusters). This meant scaling from
1 to 3 changed the pod template, triggering a restart of existing
pods. Now the quorum check is conditional at runtime: it queries
rabbit_nodes:list_running() and only runs await_online_quorum_plus_one
when more than one node is active.
Timeouts are reduced from 600s to 10s for quorum checks and 30s for
drain, fitting within the 60s terminationGracePeriodSeconds. If
quorum is already satisfied (normal rolling restart), the check passes
instantly; in degraded scenarios it times out quickly rather than
blocking.
3. Set explicit UpdateStrategy on the StatefulSet
Always set RollingUpdate with Partition=0, matching the upstream
cluster-operator. This prevents stale partition values (from migration
or manual debugging) from silently blocking pod updates.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 517307d commit ace25a4
3 files changed
Lines changed: 30 additions & 40 deletions
File tree
- internal
- controller/rabbitmq
- rabbitmq
- test/functional
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
392 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
396 | 399 | | |
| 400 | + | |
397 | 401 | | |
398 | 402 | | |
399 | 403 | | |
400 | 404 | | |
401 | 405 | | |
402 | 406 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | 407 | | |
431 | 408 | | |
432 | 409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
391 | 397 | | |
392 | 398 | | |
393 | 399 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
399 | 410 | | |
400 | 411 | | |
401 | 412 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2240 | 2240 | | |
2241 | 2241 | | |
2242 | 2242 | | |
2243 | | - | |
| 2243 | + | |
2244 | 2244 | | |
2245 | 2245 | | |
2246 | 2246 | | |
| |||
2254 | 2254 | | |
2255 | 2255 | | |
2256 | 2256 | | |
2257 | | - | |
| 2257 | + | |
2258 | 2258 | | |
2259 | 2259 | | |
2260 | 2260 | | |
| |||
2274 | 2274 | | |
2275 | 2275 | | |
2276 | 2276 | | |
2277 | | - | |
2278 | | - | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
2279 | 2282 | | |
2280 | 2283 | | |
2281 | | - | |
2282 | | - | |
| 2284 | + | |
2283 | 2285 | | |
2284 | 2286 | | |
2285 | 2287 | | |
| |||
0 commit comments