Skip to content

Commit 65bd760

Browse files
committed
Use new rabbitmq-upgrade commands in preStop hook
- as suggested by issue #255
1 parent 0677077 commit 65bd760

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

internal/resource/statefulset.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,10 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
594594
Lifecycle: &corev1.Lifecycle{
595595
PreStop: &corev1.Handler{
596596
Exec: &corev1.ExecAction{
597-
Command: []string{
598-
"/bin/bash", "-c", fmt.Sprintf("if [ ! -z \"$(cat /etc/pod-info/%s)\" ]; then exit 0; fi;", DeletionMarker) +
599-
" while true; do rabbitmq-queues check_if_node_is_quorum_critical" +
600-
" 2>&1; if [ $(echo $?) -eq 69 ]; then sleep 2; continue; fi;" +
601-
" rabbitmq-queues check_if_node_is_mirror_sync_critical" +
602-
" 2>&1; if [ $(echo $?) -eq 69 ]; then sleep 2; continue; fi; break;" +
603-
" done",
597+
Command: []string{"/bin/bash", "-c",
598+
fmt.Sprintf("if [ ! -z \"$(cat /etc/pod-info/%s)\" ]; then exit 0; fi;", DeletionMarker) +
599+
fmt.Sprintf(" rabbitmq-upgrade await_online_quorum_plus_one -t %d;"+
600+
" rabbitmq-upgrade await_online_synchronized_mirror -t %d", defaultGracePeriodTimeoutSeconds, defaultGracePeriodTimeoutSeconds),
604601
},
605602
},
606603
},

internal/resource/statefulset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ var _ = Describe("StatefulSet", func() {
996996
stsBuilder := builder.StatefulSet()
997997
Expect(stsBuilder.Update(statefulSet)).To(Succeed())
998998

999-
expectedPreStopCommand := []string{"/bin/bash", "-c", "if [ ! -z \"$(cat /etc/pod-info/skipPreStopChecks)\" ]; then exit 0; fi; while true; do rabbitmq-queues check_if_node_is_quorum_critical 2>&1; if [ $(echo $?) -eq 69 ]; then sleep 2; continue; fi; rabbitmq-queues check_if_node_is_mirror_sync_critical 2>&1; if [ $(echo $?) -eq 69 ]; then sleep 2; continue; fi; break; done"}
999+
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"}
10001000

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

0 commit comments

Comments
 (0)