Skip to content

Commit 9e67c89

Browse files
authored
Extend migrate rabbitmq3to4 check with vhost-specific detection (#1879)
Add detection for migration in progress scenarios based on vhost: - Classic queues in / AND quorum queues in /openstack - Classic queues in / AND quorum queues in / (legacy mixed setup) This improves detection accuracy when migration is partially complete or when a mixed classic/quorum setup was used previously. AI-assisted: Claude Code Signed-off-by: Christian Berendt <[email protected]>
1 parent c9de1ea commit 9e67c89

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

osism/commands/migrate.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,14 +585,47 @@ def take_action(self, parsed_args):
585585
all_queues = self._get_all_queues(base_url, auth)
586586
if all_queues is None:
587587
return 1
588+
589+
# Get queues by vhost
590+
queues_root = [q for q in all_queues if q.get("vhost", "/") == "/"]
591+
queues_openstack = [
592+
q for q in all_queues if q.get("vhost", "/") == "/openstack"
593+
]
594+
595+
# Get classic queues in / vhost
596+
classic_in_root = self._get_classic_queues(queues_root)
597+
# Get quorum queues in /openstack vhost
598+
quorum_in_openstack = self._get_quorum_queues(queues_openstack)
599+
# Get quorum queues in / vhost (legacy mixed setup)
600+
quorum_in_root = self._get_quorum_queues(queues_root)
601+
602+
# Also get totals for logging
588603
all_classic = self._get_classic_queues(all_queues)
589604
all_quorum = self._get_quorum_queues(all_queues)
590605

606+
has_classic_in_root = len(classic_in_root) > 0
607+
has_quorum_in_openstack = len(quorum_in_openstack) > 0
608+
has_quorum_in_root = len(quorum_in_root) > 0
591609
has_classic = len(all_classic) > 0
592610
has_quorum = len(all_quorum) > 0
593611

594612
logger.info(f"Found {len(all_classic)} classic queue(s)")
595613
logger.info(f"Found {len(all_quorum)} quorum queue(s)")
614+
logger.info(f" - {len(classic_in_root)} classic queue(s) in vhost /")
615+
logger.info(
616+
f" - {len(quorum_in_openstack)} quorum queue(s) in vhost /openstack"
617+
)
618+
logger.info(f" - {len(quorum_in_root)} quorum queue(s) in vhost /")
619+
620+
# Check for migration in progress scenarios:
621+
# 1. Classic queues in / AND quorum queues in /openstack
622+
# 2. Classic queues in / AND quorum queues in / (legacy mixed setup)
623+
if has_classic_in_root and (has_quorum_in_openstack or has_quorum_in_root):
624+
logger.info(
625+
"Migration is IN PROGRESS: Classic queues in / and quorum queues "
626+
"in /openstack or / found"
627+
)
628+
return 0
596629

597630
if has_classic and not has_quorum:
598631
logger.info(

0 commit comments

Comments
 (0)