Put assert in BuilderRun.GetVersion to ensure it is not accessed too early.
The logic for determining the version of a cbuildbot run depends on the
sync stage running first. If accessed before the sync stage runs it
gives incorrect results. This change puts an assertion in to make sure
this precondition holds.
To do this, cbuildbot now always sets run.attrs.release_tag after the
sync stage, even if only to None. This at least lets the GetVersion
code know that the precondition is met.
BUG=chromium:331594
TEST=unittest
TEST=Targets run with "cbuildbot --remote":
x86-generic-full
TEST=Targets run with "cbuildbot --remote --buildbot --debug":
x86-mario-paladin
master-paladin
TEST=Inspected all uses of attr "release_tag" in code to make sure having a
None value would not break any logic assumptions.
Change-Id: I3a29706cd14e9155bc22213a966d150dfc71d1af
Reviewed-on: https://chromium-review.googlesource.com/181504
Reviewed-by: Matt Tennant <mtennant@chromium.org>
Tested-by: Matt Tennant <mtennant@chromium.org>
Commit-Queue: Matt Tennant <mtennant@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 65c2dcf..bcef772 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -136,10 +136,10 @@
This class functions as an abstract parent class for various build types.
Its intended use is builder_instance.Run().
- Vars:
- build_config: The configuration dictionary from cbuildbot_config.
- options: The options provided from optparse in main().
- release_tag: The associated "chrome os version" of this build.
+ Attributes:
+ _run: The BuilderRun object for this run.
+ archive_stages: Dict of BuildConfig keys to ArchiveStage values.
+ patch_pool: TrybotPatchPool.
"""
def __init__(self, builder_run):
@@ -150,7 +150,6 @@
os.environ['CHROMEOS_OFFICIAL'] = '1'
self.archive_stages = {}
- self.release_tag = None
self.patch_pool = trybot_patch_pool.TrybotPatchPool()
def Initialize(self):
@@ -181,6 +180,8 @@
manifest_manager = getattr(self._run.attrs, 'manifest_manager', None)
if manifest_manager:
self._run.attrs.release_tag = manifest_manager.current_version
+ else:
+ self._run.attrs.release_tag = None
def _RunStage(self, stage, *args, **kwargs):
"""Wrapper to run a stage.