| 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 c3fd0dfe2d11f666b16e767ce6a5578a3b4cbcda..db1b0061f82875595c795a87a8aaae0adf1407aa 100644
|
| --- a/scripts/slave/recipe_modules/goma/api.py
|
| +++ b/scripts/slave/recipe_modules/goma/api.py
|
| @@ -12,6 +12,8 @@ class GomaApi(recipe_api.RecipeApi):
|
| self._goma_dir = None
|
| self._goma_started = False
|
|
|
| + self._goma_ctl_env = {}
|
| +
|
| @property
|
| def service_account_json_path(self):
|
| if self.m.platform.is_win:
|
| @@ -41,6 +43,14 @@ class GomaApi(recipe_api.RecipeApi):
|
| # TODO(phajdan.jr): make failures fatal after experiment.
|
| return None
|
|
|
| + @property
|
| + def goma_ctl(self):
|
| + return self.m.path.join(self._goma_dir, 'goma_ctl.py')
|
| +
|
| + @property
|
| + def build_data_dir(self):
|
| + return self.m.properties.get('build_data_dir')
|
| +
|
| def start(self, env=None, **kwargs):
|
| """Start goma compiler_proxy.
|
|
|
| @@ -49,16 +59,43 @@ class GomaApi(recipe_api.RecipeApi):
|
| """
|
| assert self._goma_dir
|
| assert not self._goma_started
|
| - if not env:
|
| - env = {}
|
| - env.update({'GOMA_SERVICE_ACCOUNT_JSON_FILE': self.service_account_json_path})
|
| - self.m.python(
|
| - name='start_goma',
|
| - script=self.m.path.join(self._goma_dir, 'goma_ctl.py'),
|
| - args=['restart'], env=env, **kwargs)
|
| - self._goma_started = True
|
|
|
| - def stop(self, goma_dir=None, **kwargs):
|
| + if self.build_data_dir:
|
| + self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = (
|
| + self.m.path.join(self.build_data_dir, 'goma_stats_proto'))
|
| + self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = (
|
| + self.m.path.join(self.build_data_dir, 'crash_report_id_file'))
|
| +
|
| + self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = (
|
| + self.service_account_json_path)
|
| +
|
| + goma_ctl_start_env = self._goma_ctl_env.copy()
|
| +
|
| + if env is not None:
|
| + goma_ctl_start_env.update(env)
|
| +
|
| + try:
|
| + self.m.python(
|
| + name='start_goma',
|
| + script=self.goma_ctl,
|
| + args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs)
|
| + self._goma_started = True
|
| + except self.m.step.InfraFailure as e: # pragma: no cover
|
| + upload_logs_name = 'upload_goma_start_failed_logs'
|
| +
|
| + try:
|
| + self.m.python(
|
| + name='stop_goma (start failure)',
|
| + script=self.goma_ctl,
|
| + args=['stop'], env=self._goma_ctl_env, **kwargs)
|
| + except self.m.step.StepFailure:
|
| + upload_logs_name = 'upload_goma_start_and_stop_failed_logs'
|
| +
|
| + self.upload_logs(name=upload_logs_name)
|
| + raise e
|
| +
|
| + def stop(self, ninja_log_outdir=None, ninja_log_compiler=None,
|
| + ninja_log_command=None, ninja_log_exit_status=None, **kwargs):
|
| """Stop goma compiler_proxy.
|
|
|
| A user MUST execute start beforehand.
|
| @@ -68,6 +105,45 @@ class GomaApi(recipe_api.RecipeApi):
|
| assert self._goma_started
|
| self.m.python(
|
| name='stop_goma',
|
| - script=self.m.path.join(self._goma_dir, 'goma_ctl.py'),
|
| - args=['stop'], **kwargs)
|
| + 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)
|
| +
|
| self._goma_started = False
|
| + self._goma_ctl_env = {}
|
| +
|
| + def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None,
|
| + ninja_log_command=None, ninja_log_exit_status=None,
|
| + name=None):
|
| + args = [
|
| + '--upload-compiler-proxy-info'
|
| + ]
|
| +
|
| + if ninja_log_outdir:
|
| + assert ninja_log_compiler is not None
|
| + assert ninja_log_command is not None
|
| + assert ninja_log_exit_status is not None
|
| +
|
| + args.extend([
|
| + '--ninja-log-outdir', ninja_log_outdir,
|
| + '--ninja-log-compiler', ninja_log_compiler,
|
| + '--ninja-log-command', ninja_log_command,
|
| + '--ninja-log-exit-status', ninja_log_exit_status,
|
| + ])
|
| +
|
| + if self.build_data_dir:
|
| + args.extend([
|
| + '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'],
|
| + '--goma-crash-report-id-file',
|
| + self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'],
|
| + '--build-data-dir', self.build_data_dir,
|
| + ])
|
| +
|
| + self.m.python(
|
| + name=name or 'upload_log',
|
| + script=self.package_repo_resource(
|
| + 'scripts', 'slave', 'upload_goma_logs.py'),
|
| + args=args
|
| + )
|
|
|