| Index: client/run_isolated.py
|
| diff --git a/client/run_isolated.py b/client/run_isolated.py
|
| index a879c221e39bdbcfb91a88c15837c2e9c90cd6b8..255f81bf1ea0d437efc28e001da9070ffe8f9329 100755
|
| --- a/client/run_isolated.py
|
| +++ b/client/run_isolated.py
|
| @@ -400,9 +400,10 @@ def map_and_run(
|
| cwd = run_dir
|
|
|
| try:
|
| - cipd_stats = install_packages_fn(run_dir)
|
| - if cipd_stats:
|
| - result['stats']['cipd'] = cipd_stats
|
| + cipd_info = install_packages_fn(run_dir)
|
| + if cipd_info:
|
| + result['stats']['cipd'] = cipd_info['stats']
|
| + result['cipd_pins'] = cipd_info['pins']
|
|
|
| if isolated_hash:
|
| isolated_stats = result['stats'].setdefault('isolated', {})
|
| @@ -539,7 +540,8 @@ def run_tha_test(
|
| grace_period: number of seconds to wait between SIGTERM and SIGKILL.
|
| extra_args: optional arguments to add to the command stated in the .isolate
|
| file. Ignored if isolate_hash is empty.
|
| - install_packages_fn: function (dir) => cipd_stats. Installs packages.
|
| + install_packages_fn: function (dir) => {"stats": cipd_stats, "pins":
|
| + cipd_pins}. Installs packages.
|
| use_symlinks: create tree with symlinks instead of hardlinks.
|
|
|
| Returns:
|
| @@ -595,11 +597,24 @@ def run_tha_test(
|
| def install_packages(
|
| run_dir, packages, service_url, client_package_name,
|
| client_version, cache_dir=None, timeout=None):
|
| - """Installs packages. Returns stats.
|
| + """Installs packages. Returns stats and pins.
|
| +
|
| + pins are in the form of:
|
| + [
|
| + {
|
| + "path": path, "package_name": package_name, "version": version,
|
| + },
|
| + ...
|
| + ]
|
| +
|
| + such that they correspond 1:1 to all input package arguments from the command
|
| + line. These dictionaries make their all the way back to swarming, where they
|
| + become the arguments of CipdPackage.
|
|
|
| Args:
|
| run_dir (str): root of installation.
|
| - packages: packages to install, dict {path: [(package_name, version)].
|
| + packages: packages to install, dict
|
| + {path: [(package_name, version, cmd_line_idx)].
|
| service_url (str): CIPD server url, e.g.
|
| "https://chrome-infra-packages.appspot.com."
|
| client_package_name (str): CIPD package name of CIPD client.
|
| @@ -617,6 +632,16 @@ def install_packages(
|
|
|
| run_dir = os.path.abspath(run_dir)
|
|
|
| + all_pins = []
|
| + def insert_pin(path, name, version, idx):
|
| + if idx > len(all_pins)-1:
|
| + all_pins.extend([None] * (len(all_pins) - idx + 1))
|
| + all_pins[idx] = {
|
| + 'package_name': name,
|
| + 'version': version,
|
| + 'path': path,
|
| + }
|
| +
|
| get_client_start = time.time()
|
| client_manager = cipd.get_client(
|
| service_url, client_package_name, client_version, cache_dir,
|
| @@ -631,19 +656,26 @@ def install_packages(
|
| # Do not clean site_root before installation because it may contain other
|
| # site roots.
|
| file_path.ensure_tree(site_root, 0770)
|
| - client.ensure(
|
| - site_root, packages,
|
| + pins = client.ensure(
|
| + site_root, [(name, vers) for name, vers, _ in packages],
|
| cache_dir=os.path.join(cache_dir, 'cipd_internal'),
|
| timeout=timeoutfn())
|
| + for i, pin in enumerate(pins):
|
| + insert_pin(path, pin[0], pin[1], packages[i])
|
| file_path.make_tree_files_read_only(site_root)
|
|
|
| total_duration = time.time() - start
|
| logging.info(
|
| 'Installing CIPD client and packages took %d seconds', total_duration)
|
|
|
| + assert None not in all_pins
|
| +
|
| return {
|
| - 'duration': total_duration,
|
| - 'get_client_duration': get_client_duration,
|
| + 'stats': {
|
| + 'duration': total_duration,
|
| + 'get_client_duration': get_client_duration,
|
| + },
|
| + 'pins': all_pins,
|
| }
|
|
|
|
|
| @@ -744,7 +776,7 @@ def main(args):
|
| cipd.validate_cipd_options(parser, options)
|
|
|
| install_packages_fn = lambda run_dir: install_packages(
|
| - run_dir, cipd.parse_package_args(options.cipd_packages),
|
| + run_dir, cipd.parse_package_args(options.cipd_packages, with_index=True),
|
| options.cipd_server, options.cipd_client_package,
|
| options.cipd_client_version, cache_dir=options.cipd_cache)
|
|
|
|
|