Automatically Export and Import Queue on RabbitMQ Chart Version Upgrades
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- helm, kubernetes, rabbitmq
- Domain
- distributed-systems, infrastructure
Research direction
No repository files or tests are named. Start by reviewing the Helm Chart Hooks documentation and RabbitMQ Backup and Restore documentation, then determine how message data can be preserved and how RabbitMQ version changes are detected. Done means upgrades and uninstalls preserve the queue without importing on unrelated Helm upgrades, with the behavior tested outside production.
Written by the indexing model from the issue text.
Description
Purpose
When changing RabbitMQ sub-chart versions, provide automatic functionality (via helm hooks) to export the queue on helm uninstall and import it on helm install (and do both on helm upgrade).
Background
Issue #202 introduced the creation of a new PV/PVC for RabbitMQ, each time RabbitMQ sub-chart is upgraded, since a fresh install bypasses onerous manual upgrade requirements.
Currently, before upgrading, the operator must ensure the RabbitMQ queue is empty, otherwise indexing tasks may be "lost" (they will still remain on the old PV, but will no longer be used by the newer RabbitMQ version).
This isn't a problem for less-trafficked installations, but could become onerous on sites like arcticdata.io, or the production CN, for example.
Potential Difficulties
-
The example below uses
rabbitmqadmin export/import; however, the rabbitMQ docs imply this processes only the Schema definition, and not the actual messages. It appears that messages may be more difficult to back up:- From Backing Up Messages:
Manually Backing Up Messages
Presently this is the only way of backing up messages. You can copy the folders mentioned above. - From Backup and Restore):
Modern versions of RabbitMQ (3.8.0+) only support backup restore from disk when they are restored to a RabbitMQ node with exactly the same node name as the node the data was backed up from
- From Backing Up Messages:
-
We need to make sure the export/import process does not interfere with helm installations and upgrades that do NOT involve a RabbitMQ version change - in those instances, we could still do the export (for safety), but the import should be skipped, since RMQ uses its own on-disk cache of the queue items
References
- Helm Chart Hooks
- RabbitMQ Backup and Restore
- Comprehensive example by @vchendrix in Issue #202:, reproduced below.
From my experience, replacing the PVC for RabbitMQ is relatively quick when there is only a single pod. However, scaling to multiple pods might indeed increase the complexity and time required.
One potential solution could be to implement a Helm hook to automate this process during upgrades. For instance, we currently use Helm hooks to trigger backups for PostgreSQL and Solr prior to upgrades and uninstalls. Similarly, a pre- and post-upgrade hook for preserving the RabbitMQ queue could streamline the process and ensure data integrity during updates ( See idea below).
To preserve RabbitMQ queues during upgrades, you can use Helm pre and post hooks. These hooks can help ensure the state is preserved and restored effectively. Depending on your setup, temporary PVCs may or may not be required. Here's an approach:
Pre-Upgrade Hook
Backup Messages in the Queue:
- Use a Helm
pre-upgradehook to export messages from RabbitMQ to a temporary storage solution (e.g., a temporary PVC or a cloud storage bucket).- Tools like
rabbitmqadminorrabbit-dump-queuecan be used to dump the queue data.Example Hook:
apiVersion: batch/v1 kind: Job metadata: name: rabbitmq-backup annotations: "helm.sh/hook": pre-upgrade spec: template: spec: containers: - name: backup image: rabbitmq:management command: ["sh", "-c", "rabbitmqadmin export /backup/queues.json"] volumeMounts: - name: backup-pvc mountPath: /backup volumes: - name: backup-pvc persistentVolumeClaim: claimName: rabbitmq-backup-pvc restartPolicy: OnFailureTemporary PVC:
- Request a temporary PVC for storing the backup during the upgrade process.
- Define a PVC with appropriate storage configuration.
Example PVC:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: rabbitmq-backup-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1GiPost-Upgrade Hook
Restore Messages to the Queue:
- Use a Helm
post-upgradehook to restore the RabbitMQ queues from the backup.- Tools like
rabbitmqadminor similar can be used to import the queue configuration and messages.Example Hook:
apiVersion: batch/v1 kind: Job metadata: name: rabbitmq-restore annotations: "helm.sh/hook": post-upgrade spec: template: spec: containers: - name: restore image: rabbitmq:management command: ["sh", "-c", "rabbitmqadmin import /backup/queues.json"] volumeMounts: - name: backup-pvc mountPath: /backup volumes: - name: backup-pvc persistentVolumeClaim: claimName: rabbitmq-backup-pvc restartPolicy: OnFailureDelete Temporary PVC (Optional):
- Add a cleanup step to delete the temporary PVC if it's no longer needed.
Example Cleanup Hook:
apiVersion: batch/v1 kind: Job metadata: name: rabbitmq-cleanup annotations: "helm.sh/hook": post-upgrade spec: template: spec: containers: - name: cleanup image: bitnami/kubectl:latest command: ["sh", "-c", "kubectl delete pvc rabbitmq-backup-pvc"] restartPolicy: OnFailureKey Points:
- Temporary PVCs can be used to ensure data persists during the upgrade process.
- Ensure proper PVC sizing and resource requests to handle your RabbitMQ queues.
- Test the pre- and post-hooks in a non-production environment to ensure they work as expected.
- Dominant language
- Java
- Stars
- 0
- Forks
- 2
- Avg merge
- 6d 6h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DataONEorg/dataone-indexer
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DataONEorg/dataone-indexer#390 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
DataONEorg/dataone-indexer#378 ·
-
K8s
Difficulty 4/5 3-5 days Newbie friendliness 38/100
DataONEorg/dataone-indexer#377 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
DataONEorg/dataone-indexer#362 · 8 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
DataONEorg/dataone-indexer#357 ·
All issues in DataONEorg/dataone-indexer
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
finos/rune-common#819 ·
Maintainers usually reply within 1 day
-
enhancement good first issue storege-module
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
sdlc-pro/spring-lens#647 ·
Maintainers usually reply within 1 day
-
lang-java needs-triage package:jni package:jni_flutter package:jnigen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
valkey-io/valkey-glide#7975 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day