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

Unified Diff: appengine/swarming/swarming_bot/bot_code/task_runner.py

Issue 2069903003: swarming: custom cipd package paths (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@cipd-win
Patch Set: fix _validate_cipd_path 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/swarming_bot/bot_code/task_runner.py
diff --git a/appengine/swarming/swarming_bot/bot_code/task_runner.py b/appengine/swarming/swarming_bot/bot_code/task_runner.py
index 2658766d13e6ffe54224f3a17874cc473d0d27a8..72712770a7732378871335ca552ae158c7d26ace 100644
--- a/appengine/swarming/swarming_bot/bot_code/task_runner.py
+++ b/appengine/swarming/swarming_bot/bot_code/task_runner.py
@@ -23,6 +23,7 @@ import signal
import sys
import time
+from utils import file_path
from utils import net
from utils import on_error
from utils import subprocess42
@@ -81,7 +82,8 @@ def get_run_isolated():
def get_isolated_cmd(
- work_dir, task_details, isolated_result, min_free_space, bot_file):
+ work_dir, task_details, isolated_result, bot_file, package_list,
+ min_free_space):
"""Returns the command to call run_isolated. Mocked in tests."""
assert (bool(task_details.command) !=
bool(task_details.isolated and task_details.isolated.get('input')))
@@ -104,16 +106,23 @@ def get_isolated_cmd(
])
if task_details.cipd_input and task_details.cipd_input.get('packages'):
- to_pkg = lambda p: '%s:%s' % (p['package_name'], p['version'])
+ package_json = {
+ # cipd_input and run_isolated.py use the same format for 'packages'
+ # property. It is a list of package JSON objects.
+ 'packages': task_details.cipd_input['packages'],
+ }
+ with open(package_list, 'wb') as f:
+ json.dump(package_json, f)
cmd.extend(
[
'--cipd-cache', os.path.join(bot_dir, 'cipd_cache'),
'--cipd-client-package',
- to_pkg(task_details.cipd_input.get('client_package')),
+ task_details.cipd_input['client_package']['package_name'],
+ '--cipd-client-version',
+ task_details.cipd_input['client_package']['version'],
+ '--cipd-package-list', package_list,
'--cipd-server', task_details.cipd_input.get('server'),
])
- for p in task_details.cipd_input['packages']:
- cmd.extend(['--cipd-package', to_pkg(p)])
cmd.extend(
[
@@ -369,8 +378,10 @@ def run_command(
post_update(swarming_server, headers_cb(), params, None, '', 0)
isolated_result = os.path.join(work_dir, 'isolated_result.json')
+ package_list = os.path.join(work_dir, 'package_list.json')
cmd = get_isolated_cmd(
- work_dir, task_details, isolated_result, min_free_space, bot_file)
+ work_dir, task_details, isolated_result, bot_file, package_list,
+ min_free_space)
# Hard timeout enforcement is deferred to run_isolated. Grace is doubled to
# give one 'grace_period' slot to the child process and one slot to upload
# the results back.
@@ -564,10 +575,8 @@ def run_command(
u'version': OUT_VERSION,
}
finally:
- try:
- os.remove(isolated_result)
- except OSError:
- pass
+ file_path.try_remove(unicode(isolated_result))
+ file_path.try_remove(unicode(package_list))
stop_headers_reader()
« no previous file with comments | « appengine/swarming/server/task_request_test.py ('k') | appengine/swarming/swarming_bot/bot_code/task_runner_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698