Skip to content

Commit 637ad8a

Browse files
committed
Improve handling of fail queues (#6781)
1 parent 6d542eb commit 637ad8a

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

scripts/reindex.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from azul import (
1010
config,
1111
reject,
12+
R,
1213
)
1314
from azul.args import (
1415
AzulArgumentHelpFormatter,
@@ -143,6 +144,10 @@ def main(argv: list[str]):
143144
reject(args.deindex and (args.delete or args.create),
144145
'--deindex is incompatible with --create and --delete.')
145146

147+
assert azul.is_valid_failed_queues_state(), R(
148+
'Operation canceled due to non-empty failed queues. Running manage_queues.py is '
149+
'required to empty the queues.')
150+
146151
deindex = args.deindex or (args.delete and not every_source)
147152
delete = args.delete and every_source
148153

@@ -184,6 +189,9 @@ def main(argv: list[str]):
184189
args.prefix, args.catalogs)
185190
else:
186191
azul.wait_for_indexer()
192+
assert azul.is_valid_failed_queues_state(), R(
193+
'Operation failed due to non empty failed queues. Use manage_queues.py to '
194+
'amend this state before retrying.')
187195

188196

189197
if __name__ == '__main__':

src/azul/azulclient.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,14 @@ def finalize_file(self,
795795
def load_file(self, catalog: CatalogName, file: JSON) -> File:
796796
return self.metadata_plugin(catalog).file_class.from_json(file)
797797

798+
def is_valid_failed_queues_state(self) -> bool:
799+
queues = set()
800+
for failed_queue in config.fail_queue_names:
801+
log.info('Checking whether queue %r is empty', failed_queue)
802+
queues.add(self.is_queue_empty(failed_queue))
803+
assert len(queues) > 0, R('Failed queues not checked', queues)
804+
return all(queues)
805+
798806

799807
class AzulClientError(RuntimeError):
800808
pass

test/integration_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
config,
9090
drs,
9191
false,
92+
R,
9293
)
9394
from azul.auth import (
9495
OAuth2,
@@ -429,6 +430,7 @@ class Catalog:
429430

430431
def _wait_for_indexer():
431432
self.azul_client.wait_for_indexer()
433+
self._empty_failed_queues_check()
432434

433435
flags = config.it_flags
434436
index, delete = ['no_' + flag not in flags for flag in ['index', 'delete']]
@@ -438,6 +440,7 @@ def _wait_for_indexer():
438440
else:
439441
log.warning('Will skip indexing due to overriding IT flag.')
440442

443+
self._empty_failed_queues_check()
441444
catalogs: list[Catalog] = []
442445
for catalog in config.integration_test_catalogs:
443446
if index:
@@ -495,6 +498,7 @@ def _wait_for_indexer():
495498
self._test_mirroring()
496499

497500
def _reset_indexer(self):
501+
self._empty_failed_queues_check()
498502
# While it's OK to erase the integration test catalog, the queues are
499503
# shared by all catalogs and we can't afford to trash them in a stable
500504
# deployment like production.
@@ -505,6 +509,11 @@ def _reset_indexer(self):
505509
delete_indices=True,
506510
create_indices=True)
507511

512+
def _empty_failed_queues_check(self):
513+
assert self.azul_client.is_valid_failed_queues_state(), R(
514+
'Failed queues are not empty. Use manage_queues.py to amend this state '
515+
'before retrying.')
516+
508517
def _test_other_endpoints(self):
509518
catalog = config.default_catalog
510519
if config.is_hca_enabled(catalog):

0 commit comments

Comments
 (0)