[autotest] Send frontend jobs to shards.
Frontend jobs on hosts that are on the shard are disallowed
currently, because the host-scheduler on master currently
ignore jobs based on meta-host, but frontend jobs have no
meta-host. This CL have the following changes:
- Make host-scheduler ignore frontend jobs that are supposed
to be picked by shard.
- Send such frontend jobs in heartbeat.
- Allow creation of frontend jobs in rpc.
TEST=Test the follows:
- Create a job on a host on shard from AFE frontend.
Observe it runs on shards and completes on master.
- Create a job on two hosts (one host on shard, the other on master)
from AFE frontend. Make sure exception is railed with correct
message.
- Run a normal dummy suite on shard, make sure normal flow still
works. Heartbeat contains the right information.
- Run a normal dummy suite on master, make sure it works.
BUG=chromium:444790
DEPLOY=apache, host-scheduler
Change-Id: Ibca3d36cb59fed695233ffdc89506364c402cc37
Reviewed-on: https://chromium-review.googlesource.com/240396
Reviewed-by: Mungyung Ryu <mkryu@google.com>
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Fang Deng <fdeng@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 6c191e1..7a058db 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -210,10 +210,10 @@
for host in hosts:
rpc_utils.check_modify_host_locking(host, update_data)
if host.shard:
- affected_shard_hostnames.add(host.shard.hostname)
+ affected_shard_hostnames.add(host.shard.rpc_hostname())
affected_host_ids.append(host.id)
- if not rpc_utils.is_shard():
+ if not utils.is_shard():
# Caution: Changing the filter from the original here. See docstring.
rpc_utils.run_rpc_on_multiple_hostnames(
'modify_hosts', affected_shard_hostnames,
@@ -780,7 +780,7 @@
"""
models.AclGroup.check_for_acl_violation_hosts(hosts)
shard_host_map = rpc_utils.bucket_hosts_by_shard(hosts)
- if shard_host_map and not rpc_utils.is_shard():
+ if shard_host_map and not utils.is_shard():
raise ValueError('The following hosts are on shards, please '
'follow the link to the shards and create jobs '
'there instead. %s.' % shard_host_map)
@@ -801,7 +801,7 @@
# Filter out hosts on a shard from those on the master, forward
# rpcs to the shard with an additional hostname__in filter, and
# create a local SpecialTask for each remaining host.
- if shard_host_map and not rpc_utils.is_shard():
+ if shard_host_map and not utils.is_shard():
hosts = [h for h in hosts if h.shard is None]
for shard, hostnames in shard_host_map.iteritems():