launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25599
[Merge] ~cjwatson/launchpad:sync-signingkeys-occasional-commit into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:sync-signingkeys-occasional-commit into launchpad:master.
Commit message:
sync-signingkeys: Commit after every 100th archive
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/393173
With 130000 or so archives in production, committing after every archive was taking too long.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:sync-signingkeys-occasional-commit into launchpad:master.
diff --git a/lib/lp/archivepublisher/scripts/sync_signingkeys.py b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
index f8d05f0..b3c4e72 100644
--- a/lib/lp/archivepublisher/scripts/sync_signingkeys.py
+++ b/lib/lp/archivepublisher/scripts/sync_signingkeys.py
@@ -245,14 +245,24 @@ class SyncSigningKeysScript(LaunchpadScript):
secret_key_path, SigningKeyType.OPENPGP)
self.injectGPG(archive, secret_key_path)
+ def _maybeCommit(self, count):
+ if self.options.dry_run:
+ transaction.abort()
+ else:
+ self.logger.info(
+ "%d %s processed; committing.",
+ count, "archive" if count == 1 else "archives")
+ transaction.commit()
+
def main(self):
archives = list(self.getArchives())
+ total = 0
for i, archive in enumerate(archives):
+ if i != 0 and i % 100 == 0:
+ self._maybeCommit(i)
self.logger.debug(
"#%s - Processing keys for archive %s.", i, archive.reference)
self.processArchive(archive)
- if self.options.dry_run:
- transaction.abort()
- else:
- transaction.commit()
+ total = i + 1
+ self._maybeCommit(total)
self.logger.info("Finished processing archives injections.")
diff --git a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
index 4f410a2..7c54063 100644
--- a/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
+++ b/lib/lp/archivepublisher/tests/test_sync_signingkeys.py
@@ -279,6 +279,8 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
SigningKeyType.UEFI, None),
content)
+ self.assertIn("INFO 1 archive processed; committing.", content)
+
def test_process_archive_dry_run(self):
signing_service_client = self.useFixture(
SigningServiceClientFixture(self.factory))
@@ -403,6 +405,7 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
"INFO Found key file %s (type=%s)." % (
secret_key_path, SigningKeyType.OPENPGP),
content)
+ self.assertIn("INFO 1 archive processed; committing.", content)
def test_process_archive_openpgp_missing(self):
archive = self.factory.makeArchive()
@@ -424,6 +427,7 @@ class TestSyncSigningKeysScript(TestCaseWithFactory):
"DEBUG #0 - Processing keys for archive %s." % archive.reference,
content)
self.assertNotIn("INFO Found key file", content)
+ self.assertIn("INFO 1 archive processed; committing.", content)
def test_inject(self):
signing_service_client = self.useFixture(