Skip to content

Commit b97a788

Browse files
committed
Add pause & resume reconciliation commands to cli plugin
1 parent a27503b commit b97a788

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

bin/kubectl-rabbitmq

+40
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ USAGE:
5252
Enable all feature flags on an INSTANCE
5353
kubectl rabbitmq enable-all-feature-flags INSTANCE
5454
55+
Pause reconciliation for an instance
56+
kubectl rabbitmq pause-reconciliation INSTANCE
57+
58+
Resume reconciliation for an instance
59+
kubectl rabbitmq resume-reconciliation INSTANCE
60+
61+
List all instances that has the pause reconciliation label
62+
kubectl rabbitmq list-pause-reconciliation-instances
63+
5564
Run perf-test against an instance - you can pass as many perf test parameters as you want
5665
kubectl rabbitmq perf-test INSTANCE --rate 100
5766
If you want to monitor perf-test, create the following ServiceMonitor:
@@ -233,6 +242,18 @@ enable_all_feature_flags() {
233242
kubectl exec "${1}-server-0" -- bash -c "rabbitmqctl list_feature_flags | grep disabled | cut -f 1 | xargs -r -L1 rabbitmqctl enable_feature_flag"
234243
}
235244

245+
pause-reconciliation() {
246+
kubectl label rabbitmqclusters "${1}" rabbitmq.com/pauseReconciliation=true
247+
}
248+
249+
resume-reconciliation() {
250+
kubectl label rabbitmqclusters "${1}" rabbitmq.com/pauseReconciliation-
251+
}
252+
253+
list-pause-reconciliation-instances() {
254+
kubectl get rabbitmqclusters -l rabbitmq.com/pauseReconciliation=true --show-labels
255+
}
256+
236257
secrets() {
237258
get_instance_details "$@"
238259
echo "username: ${username}"
@@ -330,6 +351,25 @@ main() {
330351
fi
331352
enable_all_feature_flags "$1"
332353
;;
354+
"pause-reconciliation")
355+
shift 1
356+
if [[ "$#" -ne 1 ]]; then
357+
usage
358+
exit 1
359+
fi
360+
pause-reconciliation "$1"
361+
;;
362+
"resume-reconciliation")
363+
shift 1
364+
if [[ "$#" -ne 1 ]]; then
365+
usage
366+
exit 1
367+
fi
368+
resume-reconciliation "$1"
369+
;;
370+
"list-pause-reconciliation-instances")
371+
list-pause-reconciliation-instances
372+
;;
333373
"install-cluster-operator")
334374
shift 1
335375
if [[ "$#" -gt 0 ]]; then

bin/kubectl-rabbitmq.bats

+13
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ eventually() {
9898
[[ "$output" == *"secret/bats-default-erlang-cookie"* ]]
9999
}
100100

101+
@test "pause-and-resume-reconciliation" {
102+
kubectl rabbitmq pause-reconciliation bats-default
103+
kubectl get rabbitmqclusters.rabbitmq.com bats-default --show-labels | grep rabbitmq.com/pauseReconciliation
104+
105+
run kubectl rabbitmq list-pause-reconciliation-instances
106+
107+
[ "$status" -eq 0 ]
108+
[[ "$output" == *"bats-default"* ]]
109+
110+
kubectl rabbitmq resume-reconciliation bats-default
111+
kubectl get rabbitmqclusters.rabbitmq.com bats-default --show-labels | grep none
112+
}
113+
101114
@test "secrets prints secrets of default-user" {
102115
run kubectl rabbitmq secrets bats-default
103116

0 commit comments

Comments
 (0)