← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/gpgkey-fks-no-garbo into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/gpgkey-fks-no-garbo into lp:launchpad with lp:~wgrant/launchpad/gpgkey-fks as a prerequisite.

Commit message:
Drop GPGKey FK replacement backfill garbo jobs.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/gpgkey-fks-no-garbo/+merge/287803

Drop GPGKey FK replacement backfill garbo jobs.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/gpgkey-fks-no-garbo into lp:launchpad.
=== modified file 'database/sampledata/current-dev.sql'
--- database/sampledata/current-dev.sql	2016-03-02 15:54:31 +0000
+++ database/sampledata/current-dev.sql	2016-03-02 15:54:31 +0000
@@ -9469,7 +9469,7 @@
 
 ALTER TABLE signedcodeofconduct DISABLE TRIGGER ALL;
 
-INSERT INTO signedcodeofconduct (id, owner, signingkey, datecreated, signedcode, recipient, active, admincomment, signing_key_fingerprint) VALUES (1, 16, 1, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, NULL, NULL);
+INSERT INTO signedcodeofconduct (id, owner, signingkey, datecreated, signedcode, recipient, active, admincomment, signing_key_fingerprint) VALUES (1, 16, 1, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, NULL, 'ABCDEF0123456789ABCDDCBA0000111112345678');
 
 
 ALTER TABLE signedcodeofconduct ENABLE TRIGGER ALL;

=== modified file 'database/sampledata/current.sql'
--- database/sampledata/current.sql	2016-03-02 15:54:31 +0000
+++ database/sampledata/current.sql	2016-03-02 15:54:31 +0000
@@ -9384,7 +9384,7 @@
 
 ALTER TABLE signedcodeofconduct DISABLE TRIGGER ALL;
 
-INSERT INTO signedcodeofconduct (id, owner, signingkey, datecreated, signedcode, recipient, active, admincomment, signing_key_fingerprint) VALUES (1, 16, 1, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, NULL, NULL);
+INSERT INTO signedcodeofconduct (id, owner, signingkey, datecreated, signedcode, recipient, active, admincomment, signing_key_fingerprint) VALUES (1, 16, 1, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, NULL, 'ABCDEF0123456789ABCDDCBA0000111112345678');
 
 
 ALTER TABLE signedcodeofconduct ENABLE TRIGGER ALL;

=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2016-03-02 15:54:31 +0000
+++ database/schema/security.cfg	2016-01-19 17:41:11 +0000
@@ -2277,7 +2277,6 @@
 public.accesspolicygrant                = SELECT, DELETE
 public.account                          = SELECT, DELETE
 public.answercontact                    = SELECT, DELETE
-public.archive                          = SELECT, UPDATE
 public.branch                           = SELECT, UPDATE
 public.branchjob                        = SELECT, DELETE
 public.binarypackagename                = SELECT
@@ -2319,7 +2318,6 @@
 public.milestonetag                     = SELECT
 public.openidconsumerassociation        = SELECT, DELETE
 public.openidconsumernonce              = SELECT, DELETE
-public.packageupload                    = SELECT, UPDATE
 public.person                           = SELECT, DELETE
 public.personsettings                   = SELECT, UPDATE
 public.product                          = SELECT, UPDATE
@@ -2329,10 +2327,9 @@
 public.previewdiff                      = SELECT, DELETE
 public.revisionauthor                   = SELECT, UPDATE
 public.revisioncache                    = SELECT, DELETE
-public.signedcodeofconduct              = SELECT, UPDATE
 public.snapfile                         = SELECT, DELETE
 public.sourcepackagename                = SELECT
-public.sourcepackagerelease             = SELECT, UPDATE
+public.sourcepackagerelease             = SELECT
 public.sourcepackagepublishinghistory   = SELECT, UPDATE
 public.suggestivepotemplate             = INSERT, DELETE
 public.teammembership                   = SELECT, DELETE

=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py	2016-03-02 15:54:31 +0000
+++ lib/lp/scripts/garbo.py	2016-02-05 17:18:57 +0000
@@ -69,7 +69,6 @@
     RevisionCache,
     )
 from lp.hardwaredb.model.hwdb import HWSubmission
-from lp.registry.model.codeofconduct import SignedCodeOfConduct
 from lp.registry.model.commercialsubscription import CommercialSubscription
 from lp.registry.model.person import (
     Person,
@@ -125,7 +124,6 @@
 from lp.soyuz.model.archive import Archive
 from lp.soyuz.model.livefsbuild import LiveFSFile
 from lp.soyuz.model.publishing import SourcePackagePublishingHistory
-from lp.soyuz.model.queue import PackageUpload
 from lp.soyuz.model.reporting import LatestPersonSourcePackageReleaseCache
 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
 from lp.translations.interfaces.potemplate import IPOTemplateSet
@@ -1463,78 +1461,6 @@
         transaction.commit()
 
 
-class BaseKeyMigrator(TunableLoop):
-
-    maximum_chunk_size = 5000
-
-    def __init__(self, log, abort_time=None):
-        super(BaseKeyMigrator, self).__init__(
-            log, abort_time)
-        state = load_garbo_job_state(self.__class__.__name__) or {}
-        self.start_at = state.get('next_id', 1)
-        self.store = IMasterStore(self.klass)
-
-    def findObjects(self):
-        return self.store.find(
-            self.klass,
-            self.klass.id >= self.start_at).order_by(
-                self.klass.id)
-
-    def isDone(self):
-        return (
-            not getFeatureFlag('gpg.migrator.%s' % self.klass.__name__)
-            or self.findObjects().is_empty())
-
-    def __call__(self, chunk_size):
-        objs = list(self.findObjects()[:chunk_size])
-        for obj in objs:
-            key = getattr(obj, self.fk_attr, None)
-            if self.fingerprint_attr:
-                setattr(
-                    obj, self.fingerprint_attr,
-                    key.fingerprint if key else None)
-            if self.owner_attr:
-                setattr(
-                    obj, self.owner_attr,
-                    key.owner if key else None)
-        self.start_at = objs[-1].id + 1
-        save_garbo_job_state(
-            self.__class__.__name__, {'next_id': self.start_at})
-        transaction.commit()
-
-
-class ArchiveKeyMigrator(BaseKeyMigrator):
-
-    klass = Archive
-    fk_attr = 'signing_key'
-    fingerprint_attr = '_signing_key_fingerprint'
-    owner_attr = 'signing_key_owner'
-
-
-class PackageUploadKeyMigrator(BaseKeyMigrator):
-
-    klass = PackageUpload
-    fk_attr = 'signing_key'
-    fingerprint_attr = 'signing_key_fingerprint'
-    owner_attr = 'signing_key_owner'
-
-
-class SignedCodeOfConductKeyMigrator(BaseKeyMigrator):
-
-    klass = SignedCodeOfConduct
-    fk_attr = 'signingkey'
-    fingerprint_attr = 'signing_key_fingerprint'
-    owner_attr = None
-
-
-class SourcePackageReleaseKeyMigrator(BaseKeyMigrator):
-
-    klass = SourcePackageRelease
-    fk_attr = 'dscsigningkey'
-    fingerprint_attr = 'signing_key_fingerprint'
-    owner_attr = 'signing_key_owner'
-
-
 class BaseDatabaseGarbageCollector(LaunchpadCronScript):
     """Abstract base class to run a collection of TunableLoops."""
     script_name = None  # Script name for locking and database user. Override.
@@ -1783,14 +1709,10 @@
     """
     script_name = 'garbo-hourly'
     tunable_loops = [
-        ArchiveKeyMigrator,
         BugHeatUpdater,
         BugWatchScheduler,
         DuplicateSessionPruner,
-        PackageUploadKeyMigrator,
         RevisionCachePruner,
-        SignedCodeOfConductKeyMigrator,
-        SourcePackageReleaseKeyMigrator,
         UnusedSessionPruner,
         ]
     experimental_tunable_loops = []

=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py	2016-03-02 15:54:31 +0000
+++ lib/lp/scripts/tests/test_garbo.py	2016-03-02 15:54:31 +0000
@@ -1394,67 +1394,6 @@
         self._test_LiveFSFilePruner(
             'application/octet-stream', 0, expected_count=1)
 
-    def test_ArchiveKeyMigrator(self):
-        with dbuser('testadmin'):
-            key = self.factory.makeGPGKey(self.factory.makePerson())
-            a1 = self.factory.makeArchive()
-            a2 = self.factory.makeArchive()
-            removeSecurityProxy(a2).signing_key = key
-        self.assertIs(None, a1._signing_key_fingerprint)
-        self.assertIs(None, a1.signing_key_owner)
-        self.assertIs(None, a2._signing_key_fingerprint)
-        self.assertIs(None, a2.signing_key_owner)
-        with FeatureFixture({'gpg.migrator.Archive': 'on'}):
-            self.runHourly()
-        self.assertIs(None, a1._signing_key_fingerprint)
-        self.assertIs(None, a1.signing_key_owner)
-        self.assertEqual(key.fingerprint, a2._signing_key_fingerprint)
-        self.assertEqual(key.owner, a2.signing_key_owner)
-
-    def test_PackageUploadKeyMigrator(self):
-        with dbuser('testadmin'):
-            key = self.factory.makeGPGKey(self.factory.makePerson())
-            pu1 = self.factory.makePackageUpload()
-            pu2 = self.factory.makePackageUpload(signing_key=key)
-            npu2 = removeSecurityProxy(pu2)
-            npu2.signing_key_fingerprint = npu2.signing_key_owner = None
-        self.assertIs(None, pu1.signing_key_fingerprint)
-        self.assertIs(None, pu1.signing_key_owner)
-        self.assertIs(None, pu2.signing_key_fingerprint)
-        self.assertIs(None, pu2.signing_key_owner)
-        with FeatureFixture({'gpg.migrator.PackageUpload': 'on'}):
-            self.runHourly()
-        self.assertIs(None, pu1.signing_key_fingerprint)
-        self.assertIs(None, pu1.signing_key_owner)
-        self.assertEqual(key.fingerprint, pu2.signing_key_fingerprint)
-        self.assertEqual(key.owner, pu2.signing_key_owner)
-
-    def test_SignedCodeOfConductKeyMigrator(self):
-        coc = SignedCodeOfConduct.get(1)
-        self.assertIs(None, coc.signing_key_fingerprint)
-        with FeatureFixture({'gpg.migrator.SignedCodeOfConduct': 'on'}):
-            self.runHourly()
-        self.assertEqual(
-            'ABCDEF0123456789ABCDDCBA0000111112345678',
-            coc.signing_key_fingerprint)
-
-    def test_SourcePackageReleaseKeyMigrator(self):
-        with dbuser('testadmin'):
-            key = self.factory.makeGPGKey(self.factory.makePerson())
-            spr1 = self.factory.makeSourcePackageRelease()
-            spr2 = self.factory.makeSourcePackageRelease()
-            removeSecurityProxy(spr2).dscsigningkey = key
-        self.assertIs(None, spr1.signing_key_fingerprint)
-        self.assertIs(None, spr1.signing_key_owner)
-        self.assertIs(None, spr2.signing_key_fingerprint)
-        self.assertIs(None, spr2.signing_key_owner)
-        with FeatureFixture({'gpg.migrator.SourcePackageRelease': 'on'}):
-            self.runHourly()
-        self.assertIs(None, spr1.signing_key_fingerprint)
-        self.assertIs(None, spr1.signing_key_owner)
-        self.assertEqual(key.fingerprint, spr2.signing_key_fingerprint)
-        self.assertEqual(key.owner, spr2.signing_key_owner)
-
     def test_PersonSettingsENFPopulator(self):
         switch_dbuser('testadmin')
         store = IMasterStore(PersonSettings)