diff options
Diffstat (limited to 'cbuildbot/validation_pool.py')
-rw-r--r-- | cbuildbot/validation_pool.py | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/cbuildbot/validation_pool.py b/cbuildbot/validation_pool.py index b6e96e852..15f18e9d0 100644 --- a/cbuildbot/validation_pool.py +++ b/cbuildbot/validation_pool.py @@ -822,7 +822,7 @@ class PatchSeries(object): @_ManifestDecorator def Apply(self, changes, frozen=True, honor_ordering=False, - changes_filter=None, max_change_count=None): + changes_filter=None): """Applies changes from pool into the build root specified by the manifest. This method resolves each given change down into a set of transactions- @@ -855,10 +855,6 @@ class PatchSeries(object): changes being inspected, and expand the changes if necessary. Primarily this is of use for cbuildbot patching when dealing w/ uploaded/remote patches. - max_change_count: If not None, this is a soft integer limit on the number - of patches to pull in. We stop pulling in patches as soon as we grab - at least this many patches. Note that this limit may be exceeded by N-1, - where N is the length of the longest transaction. Returns: A tuple of changes-applied, Exceptions for the changes that failed @@ -885,9 +881,6 @@ class PatchSeries(object): change, ', '.join(map(str, resolved[-1][-1]))) planned.update(plan) - if max_change_count is not None and len(planned) >= max_change_count: - break - if not resolved: # No work to do; either no changes were given to us, or all failed # to be resolved. @@ -1129,7 +1122,7 @@ class ValidationPool(object): def __init__(self, overlays, build_root, build_number, builder_name, is_master, dryrun, changes=None, non_os_changes=None, conflicting_changes=None, pre_cq_trybot=False, - tree_was_open=True, builder_run=None): + tree_was_open=True, _applied=None, builder_run=None): """Initializes an instance by setting default variables to instance vars. Generally use AcquirePool as an entry pool to a pool rather than this @@ -1151,11 +1144,12 @@ class ValidationPool(object): pre_cq_trybot: If set to True, this is a Pre-CQ trybot. (Note: The Pre-CQ launcher is NOT considered a Pre-CQ trybot.) tree_was_open: Whether the tree was open when the pool was created. + applied: List of CLs that have been applied to the current repo. Not + yet used, but needs to be here for pickling compatibility. builder_run: BuilderRun instance used to fetch cidb handle and metadata instance. Please note due to the pickling logic, this MUST be the last kwarg listed. """ - self.build_root = build_root # These instances can be instantiated via both older, or newer pickle @@ -1622,6 +1616,22 @@ class ValidationPool(object): logging.PrintBuildbotLink(s, change.url) + def FilterChangesForThrottledTree(self): + """Apply Throttled Tree logic to select patch candidates. + + If the tree is throttled, we only test a random subset of our candidate + changes. Call this to select that subset, and throw away unrelated changes. + + If the three was open when this pool was created, it does nothing. + """ + if self.tree_was_open: + return + + fail_streak = self._GetFailStreak() + test_pool_size = max(1, len(self.changes) / (2**fail_streak)) + random.shuffle(self.changes) + self.changes = self.changes[:test_pool_size] + def ApplyPoolIntoRepo(self, manifest=None): """Applies changes from pool into the directory specified by the buildroot. @@ -1640,18 +1650,11 @@ class ValidationPool(object): failed_inflight = [] patch_series = PatchSeries(self.build_root, helper_pool=self._helper_pool) - # Only try a subset of the changes if the tree was throttled. - max_change_count = len(self.changes) - if not self.tree_was_open: - random.shuffle(self.changes) - fail_streak = self._GetFailStreak() - max_change_count = max(1, len(self.changes) / (2**fail_streak)) - if self.is_master: try: # pylint: disable=E1123 applied, failed_tot, failed_inflight = patch_series.Apply( - self.changes, manifest=manifest, max_change_count=max_change_count) + self.changes, manifest=manifest) except (KeyboardInterrupt, RuntimeError, SystemExit): raise except Exception as e: |