Skip to content

Commit

Permalink
Merge pull request #622 from neicnordic/rabbitmq_consumer_timeout
Browse files Browse the repository at this point in the history
Rabbitmq consumer timeout
  • Loading branch information
jbygdell authored Jan 26, 2024
2 parents 7b35069 + bf6c4a2 commit f808cbf
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 13 deletions.
8 changes: 5 additions & 3 deletions .github/integration/rabbitmq-federation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ services:

federation_test:
command:
- /bin/sh
- /tests/rabbitmq/10_federation_test.sh
- "/bin/sh"
- "/tests/run_scripts.sh"
- "/tests/rabbitmq"
container_name: federation
depends_on:
certfixer:
Expand All @@ -49,7 +50,7 @@ services:
condition: service_started
rabbitmq:
condition: service_healthy
image: alpine:latest
image: debian:stable-slim
profiles:
- federation
volumes:
Expand Down Expand Up @@ -98,6 +99,7 @@ services:
- RABBITMQ_SERVER_CERT=/etc/rabbitmq/ssl/mq.crt
- RABBITMQ_SERVER_KEY=/etc/rabbitmq/ssl/mq.key
- RABBITMQ_SERVER_VERIFY=verify_none
- RABBITMQ_CONSUMER_TIMEOUT=1000
healthcheck:
test:
[
Expand Down
19 changes: 11 additions & 8 deletions .github/integration/tests/rabbitmq/10_federation_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ if [ -f /.dockerenv ]; then
CEGA="cegamq:15671"
fi

if [ ! "$(command -v jq)" ]; then
if [ "$(id -u)" != 0 ]; then
echo "jq is missing, unable to install it"
exit 1
fi

apk add --no-cache curl jq
fi
for t in curl jq; do
if [ ! "$(command -v $t)" ]; then
if [ "$(id -u)" != 0 ]; then
echo "$t is missing, unable to install it"
exit 1
fi

apt-get -o DPkg::Lock::Timeout=60 update >/dev/null
apt-get -o DPkg::Lock::Timeout=60 install -y "$t" >/dev/null
fi
done

RETRY_TIMES=0
until curl -s --cacert /tmp/certs/ca.crt -u guest:guest "https://$MQHOST/api/federation-links" | jq -r '.[].status' | grep running; do
Expand Down
15 changes: 15 additions & 0 deletions .github/integration/tests/rabbitmq/20_configuration_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -ex

MQHOST="localhost:15672"
if [ -f /.dockerenv ]; then
MQHOST="mq:15671"
fi

timeout=$(curl -s --cacert /tmp/certs/ca.crt -u guest:guest "https://$MQHOST/api/queues/sda/from_cega" | jq '."consumer_details"[]."consumer_timeout"')
if [ "$timeout" -ne 1000 ]; then
echo "active timeout is wrong, expected: 1000, actual: $timeout"
exit 1
fi

echo "configuration test completed successfully"
2 changes: 1 addition & 1 deletion charts/sda-mq/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: sda-mq
version: 0.7.4
version: 0.7.5
appVersion: v0.2.67
kubeVersion: '>= 1.26.0'
description: RabbitMQ component for Sensitive Data Archive (SDA) installation
Expand Down
1 change: 1 addition & 0 deletions charts/sda-mq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Parameter | Description | Default
`global.shovel.user` | Username to federated server |`""`
`global.shovel.vhost` | Vhost on federated sever to connect to |`""`
`externalPkiService.tlsPath` | If an external PKI service is used, this is the path where the certifiates are placed | `""`
`extraConfig.consumer_timeout` | message handling timeout in milliseconds | `""`
`rbacEnabled` | Use role based access control. |`true`
`revisionHistory` | Number of revisions to keep for the option to rollback a deployment | `3`
`updateStrategyType` | Update strategy type. | `RollingUpdate`
Expand Down
4 changes: 4 additions & 0 deletions charts/sda-mq/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ spec:
value: {{ template "verifyPeer" . }}
{{- end }}
{{- end }}
{{- if .Values.extraConfig.consumer_timeout }}
- name: RABBITMQ_CONSUMER_TIMEOUT
value: {{ .Values.extraConfig.consumer_timeout }}
{{- end }}
{{- if .Values.global.vhost }}
- name: MQ_VHOST
value: {{ .Values.global.vhost | quote }}
Expand Down
3 changes: 3 additions & 0 deletions charts/sda-mq/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ global:
user: ""
vhost: ""

# timeout for acking a message, in milliseconds
extraConfig:
consumer_timeout: ""

# If an external PKI infrastructure is used to supply certificates set this to true
externalPkiService:
Expand Down
3 changes: 2 additions & 1 deletion rabbitmq/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ fi
cat >/var/lib/rabbitmq/advanced.config<<-EOF
[
{rabbit, [
{default_consumer_prefetch, {false,100}}
{consumer_timeout, ${RABBITMQ_CONSUMER_TIMEOUT:-14400000}},
{default_consumer_prefetch, {false,1}}
]
}
].
Expand Down

0 comments on commit f808cbf

Please sign in to comment.