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

Side by Side Diff: scripts/slave/remote_run.py

Issue 2061213002: remote_run: use /b as base directory for temporary files when available (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 4 years, 6 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import copy 7 import copy
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 logdog_bootstrap.add_arguments(group) 81 logdog_bootstrap.add_arguments(group)
82 82
83 args = parser.parse_args(argv[1:]) 83 args = parser.parse_args(argv[1:])
84 84
85 # Keep CIPD directory between builds. 85 # Keep CIPD directory between builds.
86 cipd_path = os.path.join(os.getcwd(), '.remote_run_cipd') 86 cipd_path = os.path.join(os.getcwd(), '.remote_run_cipd')
87 _install_cipd_packages( 87 _install_cipd_packages(
88 cipd_path, cipd.CipdPackage('infra/recipes-py', 'latest')) 88 cipd_path, cipd.CipdPackage('infra/recipes-py', 'latest'))
89 89
90 with robust_tempdir.RobustTempdir( 90 with robust_tempdir.RobustTempdir(
91 prefix='.remote_run', leak=args.leak) as rt: 91 prefix='rr', leak=args.leak) as rt:
92 # Use base directory inside system temporary directory - if we use slave 92 try:
93 # one (cwd), the paths get too long. Recipes which need different paths 93 basedir = chromium_utils.FindUpward(os.getcwd(), 'b')
94 # or persistent directories should do so explicitly. 94 except chromium_utils.PathNotFound as e:
95 basedir = tempfile.gettempdir() 95 LOGGER.warn(e)
96 # Use base directory inside system temporary directory - if we use slave
97 # one (cwd), the paths get too long. Recipes which need different paths
98 # or persistent directories should do so explicitly.
99 basedir = tempfile.gettempdir()
96 100
97 # Explicitly clean up possibly leaked temporary directories 101 # Explicitly clean up possibly leaked temporary directories
98 # from previous runs. 102 # from previous runs.
99 rt.cleanup(basedir) 103 rt.cleanup(basedir)
100 104
101 tempdir = rt.tempdir(basedir) 105 tempdir = rt.tempdir(basedir)
102 LOGGER.info('Using temporary directory: [%s].', tempdir) 106 LOGGER.info('Using temporary directory: [%s].', tempdir)
103 107
104 build_data_dir = rt.tempdir(basedir) 108 build_data_dir = rt.tempdir(basedir)
105 LOGGER.info('Using build data directory: [%s].', build_data_dir) 109 LOGGER.info('Using build data directory: [%s].', build_data_dir)
106 110
107 properties = copy.copy(args.factory_properties) 111 properties = copy.copy(args.factory_properties)
108 properties.update(args.build_properties) 112 properties.update(args.build_properties)
109 properties['build_data_dir'] = build_data_dir 113 properties['build_data_dir'] = build_data_dir
110 LOGGER.info('Using properties: %r', properties) 114 LOGGER.info('Using properties: %r', properties)
111 properties_file = os.path.join(tempdir, 'remote_run_properties.json') 115 properties_file = os.path.join(tempdir, 'remote_run_properties.json')
112 with open(properties_file, 'w') as f: 116 with open(properties_file, 'w') as f:
113 json.dump(properties, f) 117 json.dump(properties, f)
114 118
115 monitoring_utils.write_build_monitoring_event(build_data_dir, properties) 119 monitoring_utils.write_build_monitoring_event(build_data_dir, properties)
116 120
117 recipe_cmd = [ 121 recipe_cmd = [
118 sys.executable, 122 sys.executable,
119 os.path.join(cipd_path, 'recipes.py'), 123 os.path.join(cipd_path, 'recipes.py'),
120 'remote_run', 124 'remote_run',
121 '--repository', args.repository, 125 '--repository', args.repository,
122 '--revision', args.revision, 126 '--revision', args.revision,
123 '--workdir', os.path.join(tempdir, 'remote_run_workdir'), 127 '--workdir', os.path.join(tempdir, 'rw'),
124 '--', 128 '--',
125 '--properties-file', properties_file, 129 '--properties-file', properties_file,
126 '--workdir', os.path.join(tempdir, 'work'), 130 '--workdir', os.path.join(tempdir, 'w'),
127 args.recipe, 131 args.recipe,
128 ] 132 ]
129 recipe_return_code = None 133 recipe_return_code = None
130 try: 134 try:
131 bs = logdog_bootstrap.bootstrap(rt, args, basedir, tempdir, properties, 135 bs = logdog_bootstrap.bootstrap(rt, args, basedir, tempdir, properties,
132 recipe_cmd) 136 recipe_cmd)
133 137
134 LOGGER.info('Bootstrapping through LogDog: %s', bs.cmd) 138 LOGGER.info('Bootstrapping through LogDog: %s', bs.cmd)
135 _ = _call(bs.cmd) 139 _ = _call(bs.cmd)
136 recipe_return_code = bs.get_result() 140 recipe_return_code = bs.get_result()
(...skipping 16 matching lines...) Expand all
153 157
154 if update_scripts.update_scripts(): 158 if update_scripts.update_scripts():
155 # Re-execute with the updated remote_run.py. 159 # Re-execute with the updated remote_run.py.
156 return _call([sys.executable] + argv) 160 return _call([sys.executable] + argv)
157 161
158 return main(argv) 162 return main(argv)
159 163
160 164
161 if __name__ == '__main__': 165 if __name__ == '__main__':
162 sys.exit(shell_main(sys.argv)) 166 sys.exit(shell_main(sys.argv))
OLDNEW
« scripts/common/chromium_utils.py ('K') | « scripts/common/chromium_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698