Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2300)

Unified Diff: scripts/slave/recipe_modules/goma/api.py

Issue 2237403002: Add cloudtail start/stop in recipe_modules/goma (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/goma/api.py
diff --git a/scripts/slave/recipe_modules/goma/api.py b/scripts/slave/recipe_modules/goma/api.py
index e134a5d5ac8731a0eff872b9889df689d907bd5c..1b77f2961161d7785752f0475b855b278a0257af 100644
--- a/scripts/slave/recipe_modules/goma/api.py
+++ b/scripts/slave/recipe_modules/goma/api.py
@@ -18,6 +18,7 @@ class GomaApi(recipe_api.RecipeApi):
def _goma_ctl_env_init(self):
self._goma_ctl_env = {}
+ self._cloudtail_pid = None
# Inherit some env vars used in goma_utils.SendGomaTsMon.
for key in ['BUILDBOT_BUILDERNAME',
@@ -37,6 +38,12 @@ class GomaApi(recipe_api.RecipeApi):
return 'C:\\creds\\service_accounts\\service-account-goma-client.json'
return '/creds/service_accounts/service-account-goma-client.json'
+ @property
+ def cloudtail_path(self):
+ if self.m.platform.is_win:
+ return 'C:\\infra-tools\\cloudtail'
+ return '/opt/infra-tools/cloudtail'
+
def ensure_goma(self, canary=False):
with self.m.step.nest('ensure_goma'):
with self.m.step.context({'infra_step': True}):
@@ -55,6 +62,9 @@ class GomaApi(recipe_api.RecipeApi):
ref='candidate'
self._goma_dir = self.m.path['cache'].join('cipd', 'goma')
self.m.cipd.ensure(self._goma_dir, {goma_package: ref})
+
+ # TODO(tikuta) download cloudtail from cipd here
+
return self._goma_dir
except self.m.step.StepFailure:
# TODO(phajdan.jr): make failures fatal after experiment.
@@ -68,6 +78,46 @@ class GomaApi(recipe_api.RecipeApi):
def build_data_dir(self):
return self.m.properties.get('build_data_dir')
+ def _start_cloudtail(self):
+ """Start cloudtail to upload compiler_proxy.INFO
+
+ Raises:
+ InfraFailure if it fails to start cloudtail
+ """
+
+ assert self._cloudtail_pid is None
+
+ step_result = self.m.python(
+ name='start cloudtail',
+ script=self.resource('cloudtail_utils.py'),
+ args=['start',
+ '--cloudtail-path', self.cloudtail_path],
+ env=self._goma_ctl_env,
+ stdout=self.m.raw_io.output(),
+ step_test_data=(
+ lambda: self.m.raw_io.test_api.stream_output('12345')),
+ infra_step=True)
+
+ self._cloudtail_pid = step_result.stdout
+
+ def _stop_cloudtail(self):
+ """Stop cloudtail started by _start_cloudtail
+
+ Raises:
+ InfraFailure if it fails to stop cloudtail
+ """
+
+ assert self._cloudtail_pid is not None
+
+ self.m.python(
+ name='stop cloudtail',
+ script=self.resource('cloudtail_utils.py'),
+ args=['stop',
+ '--killed-pid', self._cloudtail_pid],
+ infra_step=True)
+
+ self._cloudtail_pid = None
+
def start(self, env=None, **kwargs):
"""Start goma compiler_proxy.
@@ -100,6 +150,9 @@ class GomaApi(recipe_api.RecipeApi):
script=self.goma_ctl,
args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs)
self._goma_started = True
+
+ self._start_cloudtail()
+
except self.m.step.InfraFailure as e: # pragma: no cover
upload_logs_name = 'upload_goma_start_failed_logs'
@@ -120,16 +173,24 @@ class GomaApi(recipe_api.RecipeApi):
A user MUST execute start beforehand.
It is user's responsibility to handle failure of stopping compiler_proxy.
+
+ Raises:
+ StepFailure if it fails to stop goma or upload logs.
"""
+
assert self._goma_dir
assert self._goma_started
- self.m.python(
- name='stop_goma',
- script=self.goma_ctl,
- args=['stop'], env=self._goma_ctl_env, **kwargs)
- self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command,
- ninja_log_exit_status)
+ try:
+
+ self.m.python(
+ name='stop_goma',
+ script=self.goma_ctl,
+ args=['stop'], env=self._goma_ctl_env, **kwargs)
+ self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command,
ukai 2016/08/18 04:04:53 want upload ninja log even if stop goma fails?
tikuta 2016/08/18 06:17:03 Done.
+ ninja_log_exit_status)
+ finally:
+ self._stop_cloudtail()
self._goma_started = False
self._goma_ctl_env_init()

Powered by Google App Engine
This is Rietveld 408576698