← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ines-almeida/launchpad:fix-pro-enable-infer-function into launchpad:master

 

Ines Almeida has proposed merging ~ines-almeida/launchpad:fix-pro-enable-infer-function into launchpad:master.

Commit message:
Add override_timeout function to inferProEnable

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/454716

The snap builds are currently failing due to the default timeout being `None`. This ensures a value exists in the builds
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:fix-pro-enable-infer-function into launchpad:master.
diff --git a/lib/lp/scripts/garbo.py b/lib/lp/scripts/garbo.py
index bd3cfef..61cd51b 100644
--- a/lib/lp/scripts/garbo.py
+++ b/lib/lp/scripts/garbo.py
@@ -112,7 +112,6 @@ from lp.services.scripts.base import (
     SilentLaunchpadScriptFailure,
 )
 from lp.services.session.model import SessionData
-from lp.services.timeout import override_timeout
 from lp.services.verification.model.logintoken import LoginToken
 from lp.services.webapp.publisher import canonical_url
 from lp.services.webhooks.interfaces import IWebhookJobSource
@@ -2284,14 +2283,11 @@ class SnapProEnablePopulator(TunableLoop):
         return self.findSnaps().is_empty()
 
     def __call__(self, chunk_size):
-        with override_timeout(300.0):
-            snaps = list(self.findSnaps()[:chunk_size])
-            for snap in snaps:
-                snap._pro_enable = getUtility(ISnapSet).inferProEnable(
-                    snap.source
-                )
-            self.start_at = snaps[-1].id + 1
-            transaction.commit()
+        snaps = list(self.findSnaps()[:chunk_size])
+        for snap in snaps:
+            snap._pro_enable = getUtility(ISnapSet).inferProEnable(snap.source)
+        self.start_at = snaps[-1].id + 1
+        transaction.commit()
 
 
 class BaseDatabaseGarbageCollector(LaunchpadCronScript):
diff --git a/lib/lp/snappy/model/snap.py b/lib/lp/snappy/model/snap.py
index 42c1cee..197b8ae 100644
--- a/lib/lp/snappy/model/snap.py
+++ b/lib/lp/snappy/model/snap.py
@@ -128,6 +128,7 @@ from lp.services.job.model.job import Job
 from lp.services.librarian.model import LibraryFileAlias, LibraryFileContent
 from lp.services.openid.adapters.openid import CurrentOpenIDEndPoint
 from lp.services.propertycache import cachedproperty, get_property_cache
+from lp.services.timeout import override_timeout
 from lp.services.webapp.authorization import precache_permission_for_objects
 from lp.services.webapp.interfaces import ILaunchBag
 from lp.services.webapp.publisher import canonical_url
@@ -1662,7 +1663,10 @@ class SnapSet:
             return False
 
         try:
-            snapcraft_data = self.getSnapcraftYaml(context)
+            # Ensure there is a reasonable timeout set. Without this, the
+            # default in snap builds would be 'None', which do not want.
+            with override_timeout(300.0):
+                snapcraft_data = self.getSnapcraftYaml(context)
         except (
             MissingSnapcraftYaml,
             CannotFetchSnapcraftYaml,