launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25209
[Merge] ~twom/launchpad:fix-vitals-tests into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:fix-vitals-tests into launchpad:master.
Commit message:
testfix: Ensure vitals_map exist
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/389669
`updateStats` is on a timer, and requires the `vitals_map` attribute of `PrefetchedBuilderFactory` to exist. This is currently only created in the `update` method, so it's possible to race if `updateStats` is called first.
Add an init to `PrefetchedBuilderFactory` and create `vitals_map` in it.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:fix-vitals-tests into launchpad:master.
diff --git a/lib/lp/buildmaster/manager.py b/lib/lp/buildmaster/manager.py
index 3ace0d8..fb9baaa 100644
--- a/lib/lp/buildmaster/manager.py
+++ b/lib/lp/buildmaster/manager.py
@@ -257,6 +257,12 @@ class PrefetchedBuilderFactory(BaseBuilderFactory):
from cached data updated by `update`.
"""
+ def __init__(self, *args, **kwargs):
+ super(PrefetchedBuilderFactory, self).__init__(*args, **kwargs)
+ # This needs to exist to avoid race conditions between
+ # `updateStats` and `update`.
+ self.vitals_map = {}
+
def update(self):
"""See `BaseBuilderFactory`."""
transaction.abort()