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 | |
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', | |
Yoshisato Yanagisawa
2016/08/16 03:54:23
I doubt you need to remember above four because th
tikuta
2016/08/16 04:09:04
I set these variables because these variables will
| |
28 'GOMA_TMP_DIR', | |
Yoshisato Yanagisawa
2016/08/16 03:54:23
you might not need to remember GOMA_TMP_DIR becaus
tikuta
2016/08/16 04:09:04
Done.
| |
29 'TEST_TMPDIR', | |
30 'TMPDIR', | |
31 'TMP', | |
32 ]: | |
33 if key in os.environ: # pragma: no cover | |
34 self._goma_ctl_env[key] = os.environ[key] | |
35 | |
17 @property | 36 @property |
18 def service_account_json_path(self): | 37 def service_account_json_path(self): |
19 if self.m.platform.is_win: | 38 if self.m.platform.is_win: |
20 return 'C:\\creds\\service_accounts\\service-account-goma-client.json' | 39 return 'C:\\creds\\service_accounts\\service-account-goma-client.json' |
21 return '/creds/service_accounts/service-account-goma-client.json' | 40 return '/creds/service_accounts/service-account-goma-client.json' |
22 | 41 |
23 def ensure_goma(self, canary=False): | 42 def ensure_goma(self, canary=False): |
24 with self.m.step.nest('ensure_goma'): | 43 with self.m.step.nest('ensure_goma'): |
25 with self.m.step.context({'infra_step': True}): | 44 with self.m.step.context({'infra_step': True}): |
26 try: | 45 try: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 81 |
63 if self.build_data_dir: | 82 if self.build_data_dir: |
64 self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( | 83 self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( |
65 self.m.path.join(self.build_data_dir, 'goma_stats_proto')) | 84 self.m.path.join(self.build_data_dir, 'goma_stats_proto')) |
66 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( | 85 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( |
67 self.m.path.join(self.build_data_dir, 'crash_report_id_file')) | 86 self.m.path.join(self.build_data_dir, 'crash_report_id_file')) |
68 | 87 |
69 self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( | 88 self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( |
70 self.service_account_json_path) | 89 self.service_account_json_path) |
71 | 90 |
91 # GLOG_log_dir should not be set. | |
92 assert env is None or 'GLOG_log_dir' not in env | |
93 | |
72 goma_ctl_start_env = self._goma_ctl_env.copy() | 94 goma_ctl_start_env = self._goma_ctl_env.copy() |
73 | 95 |
74 if env is not None: | 96 if env is not None: |
75 goma_ctl_start_env.update(env) | 97 goma_ctl_start_env.update(env) |
76 | 98 |
77 try: | 99 try: |
78 self.m.python( | 100 self.m.python( |
79 name='start_goma', | 101 name='start_goma', |
80 script=self.goma_ctl, | 102 script=self.goma_ctl, |
81 args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) | 103 args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) |
(...skipping 23 matching lines...) Expand all Loading... | |
105 assert self._goma_started | 127 assert self._goma_started |
106 self.m.python( | 128 self.m.python( |
107 name='stop_goma', | 129 name='stop_goma', |
108 script=self.goma_ctl, | 130 script=self.goma_ctl, |
109 args=['stop'], env=self._goma_ctl_env, **kwargs) | 131 args=['stop'], env=self._goma_ctl_env, **kwargs) |
110 | 132 |
111 self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, | 133 self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, |
112 ninja_log_exit_status) | 134 ninja_log_exit_status) |
113 | 135 |
114 self._goma_started = False | 136 self._goma_started = False |
115 self._goma_ctl_env = {} | 137 self.goma_ctl_env_init() |
138 | |
116 | 139 |
117 def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, | 140 def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, |
118 ninja_log_command=None, ninja_log_exit_status=None, | 141 ninja_log_command=None, ninja_log_exit_status=None, |
119 name=None): | 142 name=None): |
120 args = [ | 143 args = [ |
121 '--upload-compiler-proxy-info' | 144 '--upload-compiler-proxy-info' |
122 ] | 145 ] |
123 | 146 |
124 if ninja_log_outdir: | 147 if ninja_log_outdir: |
125 assert ninja_log_compiler is not None | 148 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'], | 161 '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'], |
139 '--goma-crash-report-id-file', | 162 '--goma-crash-report-id-file', |
140 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], | 163 self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], |
141 '--build-data-dir', self.build_data_dir, | 164 '--build-data-dir', self.build_data_dir, |
142 ]) | 165 ]) |
143 | 166 |
144 self.m.python( | 167 self.m.python( |
145 name=name or 'upload_log', | 168 name=name or 'upload_log', |
146 script=self.package_repo_resource( | 169 script=self.package_repo_resource( |
147 'scripts', 'slave', 'upload_goma_logs.py'), | 170 'scripts', 'slave', 'upload_goma_logs.py'), |
148 args=args | 171 args=args, |
172 env=self._goma_ctl_env | |
149 ) | 173 ) |
OLD | NEW |