generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PI-1759 Add cron job to redrive DLQ messages + extend DLQ retention t…
…o 1 week (#2964) * PI-1759 Extend DLQ retention period to 1 week * PI-1759 Add cron job to redrive DLQ messages * Pin base image version * Only generate docs for projects with a tech-docs directory
- Loading branch information
1 parent
9f95b97
commit 19f27fa
Showing
21 changed files
with
177 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
2 changes: 1 addition & 1 deletion
2
...nfigurations/domain-events-and-delius.xml → ...nfigurations/domain_events_and_delius.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Redrive Dead Letter Queues | ||
|
||
A simple CronJob that redrives SQS messages from DLQs back to the source queue. | ||
|
||
## References | ||
|
||
* https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-dead-letter-queue-redrive.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM public.ecr.aws/aws-cli/aws-cli:2.15.5 | ||
|
||
USER root | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
# hadolint ignore=DL3033 | ||
RUN yum update -y && \ | ||
yum install -y shadow-utils jq && \ | ||
yum clean all && \ | ||
useradd --uid 1000 --create-home --system app && \ | ||
curl -sL https://sentry.io/get-cli/ | bash | ||
USER 1000 | ||
|
||
COPY --chown=app /scripts /scripts | ||
|
||
ENTRYPOINT ["/scripts/startup.sh"] |
12 changes: 12 additions & 0 deletions
12
projects/redrive-dead-letter-queues/container/scripts/redrive.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
eval "$(sentry-cli bash-hook --no-environ)" | ||
|
||
queue_urls=$(aws sqs list-queues --queue-name-prefix "probation-integration-$ENVIRONMENT" | jq -r '.QueueUrls[] | select(endswith("-dlq"))') | ||
|
||
for queue_url in $queue_urls | ||
do | ||
echo "Redriving $queue_url" | ||
queue_arn=$(aws sqs get-queue-attributes --attribute-names QueueArn --queue-url "$queue_url" --query Attributes.QueueArn --output text) | ||
aws sqs start-message-move-task --source-arn "$queue_arn" | ||
done |
4 changes: 4 additions & 0 deletions
4
projects/redrive-dead-letter-queues/container/scripts/startup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
eval "$(sentry-cli bash-hook --no-environ)" | ||
sentry-cli monitors run -e "$SENTRY_ENVIRONMENT" redrive-dead-letter-queues -- /scripts/redrive.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v2 | ||
appVersion: '1.0' | ||
description: A Helm chart for Kubernetes | ||
name: redrive-dead-letter-queues | ||
version: 1.0.0 |
42 changes: 42 additions & 0 deletions
42
projects/redrive-dead-letter-queues/deploy/templates/cronjob.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: dlq-redrive | ||
spec: | ||
schedule: {{ .Values.dlq_redrive.schedule }} | ||
concurrencyPolicy: Replace | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
serviceAccountName: hmpps-probation-integration-services | ||
containers: | ||
- name: dlq-redrive | ||
image: "ghcr.io/ministryofjustice/hmpps-probation-integration-services/redrive-dead-letter-queues:{{ .Values.version }}" | ||
resources: | ||
requests: | ||
memory: 100Mi | ||
cpu: "0.1" | ||
limits: | ||
memory: 500Mi | ||
cpu: "1" | ||
env: | ||
- name: AWS_REGION | ||
value: eu-west-2 | ||
- name: ENVIRONMENT | ||
value: {{ .Values.dlq_redrive.environment }} | ||
- name: SENTRY_ENVIRONMENT | ||
value: {{ .Values.dlq_redrive.environment }} | ||
- name: SENTRY_DSN | ||
valueFrom: | ||
secretKeyRef: | ||
name: redrive-dead-letter-queues-sentry | ||
key: SENTRY_DSN | ||
optional: false | ||
- name: SENTRY_AUTH_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: redrive-dead-letter-queues-sentry | ||
key: SENTRY_AUTH_TOKEN | ||
optional: false | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dlq_redrive: | ||
environment: dev |
2 changes: 2 additions & 0 deletions
2
projects/redrive-dead-letter-queues/deploy/values-preprod.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dlq_redrive: | ||
environment: preprod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dlq_redrive: | ||
environment: prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dlq_redrive: | ||
schedule: 30 5 * * 1 # Every Monday at 05:30 UTC |
Oops, something went wrong.