[autotest]only accept hosts when both hosts and meta_hosts given for a clone job
When cloning a job via autotest frontend, if user chooses the default
clone action, which is 'Reuse any similar hosts' and then later still
select specific hosts in the next tab, the host scheduler will get
confused about the case and would try to schedule two same jobs to one
host. In this case, the host scheduler will crash because of duplicate entries
for one job in the database. The fix is to only accept the hosts
variables under this situation.
BUG=chromium:611064
TEST=unittest
Change-Id: Id945a9f8f2b45271c903f1ec038366da47f5d436
Reviewed-on: https://chromium-review.googlesource.com/366795
Commit-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Shuqian Zhao <shuqianz@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index d5de365..87ea9f5 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -910,6 +910,11 @@
"""
if is_cloning:
logging.info('Start to clone a new job')
+ # When cloning a job, hosts and meta_hosts should not exist together,
+ # which would cause host-scheduler to schedule two hqe jobs to one host
+ # at the same time, and crash itself. Clear meta_hosts for this case.
+ if kwargs.get('hosts') and kwargs.get('meta_hosts'):
+ kwargs['meta_hosts'] = []
else:
logging.info('Start to create a new job')
control_file = rpc_utils.encode_ascii(control_file)