From 2e81e55c56c8f4a3d076589460c6482e0261145c Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Wed, 27 Apr 2016 17:11:20 +0000 Subject: [PATCH] undo_items: Gracefully handle skipped cruft items in undo In 203466b, we stopped migrating cruft items if they were not in testing already. However, if the migration failed we would still attempt to undo it from testing, which (unsurprisingly) does not work very well. Signed-off-by: Niels Thykier --- britney_util.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/britney_util.py b/britney_util.py index 2e366ec..c7d0265 100644 --- a/britney_util.py +++ b/britney_util.py @@ -123,10 +123,17 @@ def undo_changes(lundo, inst_tester, sources, binaries, all_binary_packages, # undo all new binaries (consequence of the above) for (undo, item) in lundo: if not item.is_removal and item.package in sources[item.suite]: - for pkg_id in sources[item.suite][item.package][BINARIES]: + source_data = sources[item.suite][item.package] + for pkg_id in source_data[BINARIES]: binary, _, arch = pkg_id if item.architecture in ['source', arch]: - del binaries["testing"][arch][0][binary] + try: + del binaries["testing"][arch][0][binary] + except KeyError: + # If this happens, pkg_id must be a cruft item that + # was *not* migrated. + assert source_data[VERSION] != all_binary_packages[pkg_id][VERSION] + assert not inst_tester.any_of_these_are_in_testing((pkg_id,)) inst_tester.remove_testing_binary(pkg_id)