Skip to content

Commit e12a397

Browse files
authored
Put nodes into maintenance mode in preStop hook (#378)
* Put nodes into maintenance mode in preStop hook This commit causes nodes to go into maintenance mode before the controller runtime terminates the rabbitmq-server process on a pod stop. This allows for a more controlled shutdown of pods in a cluster during rolling restart, or upgrade. Using github.com/Vanlightly/RabbitTestTool, I was able to show that with these changes, no data loss, or serious periods of cluster unavailability, were caused during a rolling restart. However, this is the case without these changes; I attempted to find a demonstrable case where this change leads to an improvement in rolling restart reliability, however was not able to improve this beyond its current reliability. I still put this PR forward for review, as the core team recommend that nodes are put into maintenance mode before being stopped, to allow more predictable transfer of responsibility to other nodes. The `rabbitmq-upgrade drain` command is also able to be expanded in the future if there are further improvements that can be made in the future. This closes #320. * Update minimum RMQ version to 3.8.8 Maintenance mode is not available in previous versions of RabbitMQ
1 parent ad30e19 commit e12a397

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ under `site/kubernetes`.
3939

4040
## Supported Versions
4141

42-
The operator deploys RabbitMQ `3.8.8` by default, and supports versions from `3.8.4` upwards. The operator requires Kubernetes `1.16` or newer.
42+
The operator deploys RabbitMQ `3.8.8` by default, and supports versions from `3.8.8` upwards. The operator requires Kubernetes `1.16` or newer.
4343

4444
## Versioning
4545

internal/resource/statefulset.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
620620
Command: []string{"/bin/bash", "-c",
621621
fmt.Sprintf("if [ ! -z \"$(cat /etc/pod-info/%s)\" ]; then exit 0; fi;", DeletionMarker) +
622622
fmt.Sprintf(" rabbitmq-upgrade await_online_quorum_plus_one -t %d;"+
623-
" rabbitmq-upgrade await_online_synchronized_mirror -t %d", defaultGracePeriodTimeoutSeconds, defaultGracePeriodTimeoutSeconds),
623+
" rabbitmq-upgrade await_online_synchronized_mirror -t %d;"+
624+
" rabbitmq-upgrade drain -t %d", defaultGracePeriodTimeoutSeconds, defaultGracePeriodTimeoutSeconds, defaultGracePeriodTimeoutSeconds),
624625
},
625626
},
626627
},

internal/resource/statefulset_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ var _ = Describe("StatefulSet", func() {
10061006
stsBuilder := builder.StatefulSet()
10071007
Expect(stsBuilder.Update(statefulSet)).To(Succeed())
10081008

1009-
expectedPreStopCommand := []string{"/bin/bash", "-c", "if [ ! -z \"$(cat /etc/pod-info/skipPreStopChecks)\" ]; then exit 0; fi; rabbitmq-upgrade await_online_quorum_plus_one -t 604800; rabbitmq-upgrade await_online_synchronized_mirror -t 604800"}
1009+
expectedPreStopCommand := []string{"/bin/bash", "-c", "if [ ! -z \"$(cat /etc/pod-info/skipPreStopChecks)\" ]; then exit 0; fi; rabbitmq-upgrade await_online_quorum_plus_one -t 604800; rabbitmq-upgrade await_online_synchronized_mirror -t 604800; rabbitmq-upgrade drain -t 604800"}
10101010

10111011
Expect(statefulSet.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(Equal(expectedPreStopCommand))
10121012
})

0 commit comments

Comments
 (0)