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

Side by Side Diff: scripts/slave/recipe_modules/goma/api.py

Issue 2245553002: Inherit appropiate environment variables in goma module for goma_utils.py (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/goma/example.expected/linux.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os
6
5 from recipe_engine import recipe_api 7 from recipe_engine import recipe_api
6 8
7 class GomaApi(recipe_api.RecipeApi): 9 class GomaApi(recipe_api.RecipeApi):
8 """GomaApi contains helper functions for using goma.""" 10 """GomaApi contains helper functions for using goma."""
9 11
10 def __init__(self, **kwargs): 12 def __init__(self, **kwargs):
11 super(GomaApi, self).__init__(**kwargs) 13 super(GomaApi, self).__init__(**kwargs)
12 self._goma_dir = None 14 self._goma_dir = None
13 self._goma_started = False 15 self._goma_started = False
14 16
17 self.goma_ctl_env_init()
18
19
20 def goma_ctl_env_init(self):
15 self._goma_ctl_env = {} 21 self._goma_ctl_env = {}
16 22
23 # inherit some env vars used in goma_utils.SendGomaTsMon
24 for key in ['BUILDBOD_BUILDERNAME',
25 'BUILDBOT_MASTERNAME',
26 'BUILDBOT_SLAVENAME',
27 'BUILDBOT_CLOBBER',
28 ]:
29 self._goma_ctl_env[key] = os.environ.get(key, 'unknown')
30
17 @property 31 @property
18 def service_account_json_path(self): 32 def service_account_json_path(self):
19 if self.m.platform.is_win: 33 if self.m.platform.is_win:
20 return 'C:\\creds\\service_accounts\\service-account-goma-client.json' 34 return 'C:\\creds\\service_accounts\\service-account-goma-client.json'
21 return '/creds/service_accounts/service-account-goma-client.json' 35 return '/creds/service_accounts/service-account-goma-client.json'
22 36
23 def ensure_goma(self, canary=False): 37 def ensure_goma(self, canary=False):
24 with self.m.step.nest('ensure_goma'): 38 with self.m.step.nest('ensure_goma'):
25 with self.m.step.context({'infra_step': True}): 39 with self.m.step.context({'infra_step': True}):
26 try: 40 try:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 76
63 if self.build_data_dir: 77 if self.build_data_dir:
64 self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( 78 self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = (
65 self.m.path.join(self.build_data_dir, 'goma_stats_proto')) 79 self.m.path.join(self.build_data_dir, 'goma_stats_proto'))
66 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( 80 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = (
67 self.m.path.join(self.build_data_dir, 'crash_report_id_file')) 81 self.m.path.join(self.build_data_dir, 'crash_report_id_file'))
68 82
69 self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( 83 self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = (
70 self.service_account_json_path) 84 self.service_account_json_path)
71 85
86 assert env is None or 'GOMA_TMP_DIR' not in env
87 self._goma_ctl_env['GOMA_TMP_DIR'] = self.m.path.mkdtemp('goma_tmp_dir')
ukai 2016/08/12 04:22:30 can we make sure all gomacc invocation will have t
tikuta 2016/08/12 04:55:27 I changed to use GLOG_log_dir instead of GOMA_TMP_
88
72 goma_ctl_start_env = self._goma_ctl_env.copy() 89 goma_ctl_start_env = self._goma_ctl_env.copy()
73 90
74 if env is not None: 91 if env is not None:
75 goma_ctl_start_env.update(env) 92 goma_ctl_start_env.update(env)
76 93
77 try: 94 try:
78 self.m.python( 95 self.m.python(
79 name='start_goma', 96 name='start_goma',
80 script=self.goma_ctl, 97 script=self.goma_ctl,
81 args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) 98 args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs)
(...skipping 23 matching lines...) Expand all
105 assert self._goma_started 122 assert self._goma_started
106 self.m.python( 123 self.m.python(
107 name='stop_goma', 124 name='stop_goma',
108 script=self.goma_ctl, 125 script=self.goma_ctl,
109 args=['stop'], env=self._goma_ctl_env, **kwargs) 126 args=['stop'], env=self._goma_ctl_env, **kwargs)
110 127
111 self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, 128 self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command,
112 ninja_log_exit_status) 129 ninja_log_exit_status)
113 130
114 self._goma_started = False 131 self._goma_started = False
115 self._goma_ctl_env = {} 132 self.goma_ctl_env_init()
133
116 134
117 def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, 135 def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None,
118 ninja_log_command=None, ninja_log_exit_status=None, 136 ninja_log_command=None, ninja_log_exit_status=None,
119 name=None): 137 name=None):
120 args = [ 138 args = [
121 '--upload-compiler-proxy-info' 139 '--upload-compiler-proxy-info'
122 ] 140 ]
123 141
124 if ninja_log_outdir: 142 if ninja_log_outdir:
125 assert ninja_log_compiler is not None 143 assert ninja_log_compiler is not None
(...skipping 12 matching lines...) Expand all
138 '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'], 156 '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'],
139 '--goma-crash-report-id-file', 157 '--goma-crash-report-id-file',
140 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], 158 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'],
141 '--build-data-dir', self.build_data_dir, 159 '--build-data-dir', self.build_data_dir,
142 ]) 160 ])
143 161
144 self.m.python( 162 self.m.python(
145 name=name or 'upload_log', 163 name=name or 'upload_log',
146 script=self.package_repo_resource( 164 script=self.package_repo_resource(
147 'scripts', 'slave', 'upload_goma_logs.py'), 165 'scripts', 'slave', 'upload_goma_logs.py'),
148 args=args 166 args=args,
167 env=self._goma_ctl_env
149 ) 168 )
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/goma/example.expected/linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698