Revert "[swarming] Always set --cipd-cache to <botdir>/cipd_cache"
This reverts commit db56c585d17a553147cebd68f59a1cd88889779b.
Reason for revert: sets wrong CIPD_CACHE_DIR env var.
Original change's description:
> [swarming] Always set --cipd-cache to <botdir>/cipd_cache
>
> `--cipd-cache` specifies where to install and cache `cipd`, `cas` and other `cipd` packages required for task. Before this change there were two possible ways `--cipd-cache` would be set in `run_isolated.py`.
> 1. set to `<root_dir>/cipd_cache` where `root_dir` is bot working directory iff there exists `cipd_input` in task_slice properties - in other words more packages to install.
> 2. set to a random directory temporary directory otherwise.
>
> In (1.) the cache would not be deleted between runs. In (2.) it would be.
>
> This CL does two things:
> 1. Never sets the `--cipd-cache` argument of `run_isolated.py` to a temp directory. This was causing issues with anti virus sometimes.
> 2. Do not delete `--cipd-cache` directory after each run of `run_isolated.py`. This was the behaviour before if no `cipd_input` was specified in the `task_slice` properties. It seems quite wasteful and different from the other case.
>
> Bug: 1395532
> Change-Id: I6abaea93457f7b1fb7aa0e7961f70727a8c11270
> Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-py/+/4087207
> Auto-Submit: Jonah Hooper <jonahhooper@google.com>
> Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
> Commit-Queue: Jonah Hooper <jonahhooper@google.com>
Bug: 1395532
Change-Id: I8b17b366b7c2568c874d96c5912ce2d81534dd05
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-py/+/4162393
Reviewed-by: Justin Luong <justinluong@google.com>
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
NOKEYCHECK=True
GitOrigin-RevId: 49df67a36b6787d2c6a27e13e211628e9d9cfa34
diff --git a/cipd.py b/cipd.py
index 54d77ff..e68d28f 100644
--- a/cipd.py
+++ b/cipd.py
@@ -95,9 +95,7 @@
'--cipd-cache',
help='CIPD cache directory, separate from isolate cache. '
'Only relevant with --cipd-enabled or --cipd-package. '
- 'Default: "%default". Is only actually set in unit tests. '
- '`run_isolated.py` sets this as $bot_dir/cipd_cache if `--cipd-enabled` '
- 'is set. ',
+ 'Default: "%default".',
default='')
parser.add_option_group(group)
diff --git a/run_isolated.py b/run_isolated.py
index 5924db3..3526d6c 100755
--- a/run_isolated.py
+++ b/run_isolated.py
@@ -1652,11 +1652,12 @@
cipd.validate_cipd_options(parser, options)
install_packages_fn = copy_local_packages
+ tmp_cipd_cache_dir = None
if options.cipd_enabled:
- if options.cipd_cache:
- cipd_cache_dir = options.cipd_cache
- else:
- cipd_cache_dir = os.path.join(options.root_dir, 'cipd_cache')
+ cache_dir = options.cipd_cache
+ if not cache_dir:
+ tmp_cipd_cache_dir = tempfile.mkdtemp()
+ cache_dir = tmp_cipd_cache_dir
install_packages_fn = (
lambda run_dir, cas_dir, nsjail_dir: install_client_and_packages(
run_dir,
@@ -1664,7 +1665,7 @@
options.cipd_server,
options.cipd_client_package,
options.cipd_client_version,
- cache_dir=cipd_cache_dir,
+ cache_dir=cache_dir,
cas_dir=cas_dir,
nsjail_dir=nsjail_dir,
))
@@ -1768,6 +1769,15 @@
print(ex.message, file=sys.stderr)
on_error.report(None)
return 1
+ finally:
+ if tmp_cipd_cache_dir is not None:
+ try:
+ file_path.rmtree(tmp_cipd_cache_dir)
+ except OSError:
+ logging.exception('Remove tmp_cipd_cache_dir=%s failed',
+ tmp_cipd_cache_dir)
+ # Best effort clean up. Failed to do so doesn't affect the outcome.
+
if __name__ == '__main__':
subprocess42.inhibit_os_error_reporting()