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

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: do not wait killed_pid 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 db1b0061f82875595c795a87a8aaae0adf1407aa..aea244cc3b991263c4799847332c9e9027f6e0af 100644
--- a/scripts/slave/recipe_modules/goma/api.py
+++ b/scripts/slave/recipe_modules/goma/api.py
@@ -13,6 +13,7 @@ class GomaApi(recipe_api.RecipeApi):
self._goma_started = False
self._goma_ctl_env = {}
+ self._cloudtail_pid = None
@property
def service_account_json_path(self):
@@ -20,6 +21,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}):
@@ -38,6 +45,10 @@ 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
+
+
Paweł Hajdan Jr. 2016/08/17 06:27:01 nit: Remove redundant empty line.
tikuta 2016/08/17 07:51:32 Done.
return self._goma_dir
except self.m.step.StepFailure:
# TODO(phajdan.jr): make failures fatal after experiment.
@@ -51,6 +62,43 @@ 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',
+ '--cloudtail-path', self.cloudtail_path],
+ env=self._goma_ctl_env,
+ stdout=self.m.raw_io.output(),
+ infra_step=True)
Paweł Hajdan Jr. 2016/08/17 06:27:01 Consider adding default step_test_data=lambda: sel
tikuta 2016/08/17 07:51:32 Done.
+
+ 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=['--killed-pid', self._cloudtail_pid],
+ infra_step=True)
+
+ self._cloudtail_pid = None
+
def start(self, env=None, **kwargs):
"""Start goma compiler_proxy.
@@ -80,6 +128,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'
@@ -100,16 +151,28 @@ 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,
+ ninja_log_exit_status)
+
+ except self.m.step.StepFailure as e: # pragma: no cover
+ self._stop_cloudtail()
Paweł Hajdan Jr. 2016/08/17 06:27:01 Why not use "finally" to call _stop_cloudtail inst
tikuta 2016/08/17 07:51:32 Done.
+ raise e
+
+ self._stop_cloudtail()
self._goma_started = False
self._goma_ctl_env = {}

Powered by Google App Engine
This is Rietveld 408576698