Skip to content

Commit

Permalink
Merge pull request #317 from rabbitmq/update-commands
Browse files Browse the repository at this point in the history
Use new rabbitmq-upgrade commands in preStop hook
  • Loading branch information
ChunyiLyu authored Sep 8, 2020
2 parents ac9e368 + 65bd760 commit d841f07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions internal/resource/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,10 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
Lifecycle: &corev1.Lifecycle{
PreStop: &corev1.Handler{
Exec: &corev1.ExecAction{
Command: []string{
"/bin/bash", "-c", fmt.Sprintf("if [ ! -z \"$(cat /etc/pod-info/%s)\" ]; then exit 0; fi;", DeletionMarker) +
" 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",
Command: []string{"/bin/bash", "-c",
fmt.Sprintf("if [ ! -z \"$(cat /etc/pod-info/%s)\" ]; then exit 0; fi;", DeletionMarker) +
fmt.Sprintf(" rabbitmq-upgrade await_online_quorum_plus_one -t %d;"+
" rabbitmq-upgrade await_online_synchronized_mirror -t %d", defaultGracePeriodTimeoutSeconds, defaultGracePeriodTimeoutSeconds),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ var _ = Describe("StatefulSet", func() {
stsBuilder := builder.StatefulSet()
Expect(stsBuilder.Update(statefulSet)).To(Succeed())

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"}
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"}

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

0 comments on commit d841f07

Please sign in to comment.