From 95b71e0ddbc1bb3febb6e997016d91b9426aae91 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 7 Sep 2017 12:24:00 +0100 Subject: [PATCH] autopkgtest: Save pending.json after every test request We just had the autopkgtest queues DoSed because britney was crashing after requesting each reverse dependency for a perl upload, but before it had written pending.json out so it knew what not to request again. This was 25,000 requests per arch... Let's write pending.json straight after sending each request, so that the next run - even after a crash - won't re-request the same things again. --- britney2/policies/autopkgtest.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index 8f9655e..6cb37ae 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -339,6 +339,13 @@ class AutopkgtestPolicy(BasePolicy): return valid_version + def save_pending_json(self): + # update the pending tests on-disk cache + self.logger.info('Updating pending requested tests in %s' % self.pending_tests_file) + with open(self.pending_tests_file + '.new', 'w') as f: + json.dump(self.pending_tests, f, indent=2) + os.rename(self.pending_tests_file + '.new', self.pending_tests_file) + def save_state(self, britney): super().save_state(britney) @@ -352,11 +359,7 @@ class AutopkgtestPolicy(BasePolicy): json.dump(test_results, f, indent=2) os.rename(self.results_cache_file + '.new', self.results_cache_file) - # update the pending tests on-disk cache - self.logger.info('Updating pending requested tests in %s', self.pending_tests_file) - with open(self.pending_tests_file + '.new', 'w') as f: - json.dump(self.pending_tests, f, indent=2) - os.rename(self.pending_tests_file + '.new', self.pending_tests_file) + self.save_pending_json() def apply_src_policy_impl(self, tests_info, item, source_data_tdist, source_data_srcdist, excuse): # initialize @@ -1043,6 +1046,8 @@ class AutopkgtestPolicy(BasePolicy): arch_list.append(arch) arch_list.sort() self.send_test_request(src, arch, full_trigger, huge=huge) + # save pending.json right away, so that we don't re-request if britney crashes + self.save_pending_json() def result_in_baseline(self, src, arch): '''Get the result for src on arch in the baseline