OLD | NEW |
---|---|
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 | |
Paweł Hajdan Jr.
2016/08/17 06:31:05
nit: Remove redundant empty line (in a class the h
tikuta
2016/08/17 06:57:27
Done.
| |
20 def goma_ctl_env_init(self): | |
Paweł Hajdan Jr.
2016/08/17 06:31:06
Just checking: did you intend to make this part of
tikuta
2016/08/17 06:57:27
Done.
| |
15 self._goma_ctl_env = {} | 21 self._goma_ctl_env = {} |
16 | 22 |
23 # inherit some env vars used in goma_utils.SendGomaTsMon | |
Paweł Hajdan Jr.
2016/08/17 06:31:05
nit: Start with capital letter (i -> I), end the s
tikuta
2016/08/17 06:57:27
Done.
| |
24 for key in ['BUILDBOD_BUILDERNAME', | |
Paweł Hajdan Jr.
2016/08/17 06:31:05
nit: typo BUILDBOD -> BUILDBOT
tikuta
2016/08/17 06:57:27
Done.
| |
25 'BUILDBOT_MASTERNAME', | |
26 'BUILDBOT_SLAVENAME', | |
27 'BUILDBOT_CLOBBER', | |
28 'TEST_TMPDIR', | |
29 'TMPDIR', | |
30 'TMP', | |
31 ]: | |
32 if key in os.environ: # pragma: no cover | |
33 self._goma_ctl_env[key] = os.environ[key] | |
34 | |
17 @property | 35 @property |
18 def service_account_json_path(self): | 36 def service_account_json_path(self): |
19 if self.m.platform.is_win: | 37 if self.m.platform.is_win: |
20 return 'C:\\creds\\service_accounts\\service-account-goma-client.json' | 38 return 'C:\\creds\\service_accounts\\service-account-goma-client.json' |
21 return '/creds/service_accounts/service-account-goma-client.json' | 39 return '/creds/service_accounts/service-account-goma-client.json' |
22 | 40 |
23 def ensure_goma(self, canary=False): | 41 def ensure_goma(self, canary=False): |
24 with self.m.step.nest('ensure_goma'): | 42 with self.m.step.nest('ensure_goma'): |
25 with self.m.step.context({'infra_step': True}): | 43 with self.m.step.context({'infra_step': True}): |
26 try: | 44 try: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 80 |
63 if self.build_data_dir: | 81 if self.build_data_dir: |
64 self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( | 82 self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( |
65 self.m.path.join(self.build_data_dir, 'goma_stats_proto')) | 83 self.m.path.join(self.build_data_dir, 'goma_stats_proto')) |
66 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( | 84 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( |
67 self.m.path.join(self.build_data_dir, 'crash_report_id_file')) | 85 self.m.path.join(self.build_data_dir, 'crash_report_id_file')) |
68 | 86 |
69 self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( | 87 self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( |
70 self.service_account_json_path) | 88 self.service_account_json_path) |
71 | 89 |
90 # GLOG_log_dir should not be set. | |
91 assert env is None or 'GLOG_log_dir' not in env | |
92 | |
72 goma_ctl_start_env = self._goma_ctl_env.copy() | 93 goma_ctl_start_env = self._goma_ctl_env.copy() |
73 | 94 |
74 if env is not None: | 95 if env is not None: |
75 goma_ctl_start_env.update(env) | 96 goma_ctl_start_env.update(env) |
76 | 97 |
77 try: | 98 try: |
78 self.m.python( | 99 self.m.python( |
79 name='start_goma', | 100 name='start_goma', |
80 script=self.goma_ctl, | 101 script=self.goma_ctl, |
81 args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) | 102 args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) |
(...skipping 23 matching lines...) Expand all Loading... | |
105 assert self._goma_started | 126 assert self._goma_started |
106 self.m.python( | 127 self.m.python( |
107 name='stop_goma', | 128 name='stop_goma', |
108 script=self.goma_ctl, | 129 script=self.goma_ctl, |
109 args=['stop'], env=self._goma_ctl_env, **kwargs) | 130 args=['stop'], env=self._goma_ctl_env, **kwargs) |
110 | 131 |
111 self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, | 132 self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, |
112 ninja_log_exit_status) | 133 ninja_log_exit_status) |
113 | 134 |
114 self._goma_started = False | 135 self._goma_started = False |
115 self._goma_ctl_env = {} | 136 self.goma_ctl_env_init() |
137 | |
116 | 138 |
117 def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, | 139 def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, |
118 ninja_log_command=None, ninja_log_exit_status=None, | 140 ninja_log_command=None, ninja_log_exit_status=None, |
119 name=None): | 141 name=None): |
120 args = [ | 142 args = [ |
121 '--upload-compiler-proxy-info' | 143 '--upload-compiler-proxy-info' |
122 ] | 144 ] |
123 | 145 |
124 if ninja_log_outdir: | 146 if ninja_log_outdir: |
125 assert ninja_log_compiler is not None | 147 assert ninja_log_compiler is not None |
(...skipping 12 matching lines...) Expand all Loading... | |
138 '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'], | 160 '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'], |
139 '--goma-crash-report-id-file', | 161 '--goma-crash-report-id-file', |
140 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], | 162 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], |
141 '--build-data-dir', self.build_data_dir, | 163 '--build-data-dir', self.build_data_dir, |
142 ]) | 164 ]) |
143 | 165 |
144 self.m.python( | 166 self.m.python( |
145 name=name or 'upload_log', | 167 name=name or 'upload_log', |
146 script=self.package_repo_resource( | 168 script=self.package_repo_resource( |
147 'scripts', 'slave', 'upload_goma_logs.py'), | 169 'scripts', 'slave', 'upload_goma_logs.py'), |
148 args=args | 170 args=args, |
171 env=self._goma_ctl_env | |
149 ) | 172 ) |
OLD | NEW |