[autotest] Check host locking on batch most modifications.
If a batch host modify RPC would lock a host that is already locked,
fail hard and do not modify any of the hosts.
BUG=chromium:238025
TEST=restarted apache, modify_hosts now throws ValidationError
DEPLOY=apache
Change-Id: Ia12ba1346743c6b9608ca497ba60cb5cd25e829e
Reviewed-on: https://gerrit.chromium.org/gerrit/51227
Tested-by: Alex Miller <milleral@chromium.org>
Reviewed-by: Tan Gao <tgao@chromium.org>
Commit-Queue: Alex Miller <milleral@chromium.org>
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index b1e058d..f9d17e8 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -139,6 +139,9 @@
"""
rpc_utils.check_modify_host(update_data)
hosts = models.Host.query_objects(host_filter_data)
+ # Check all hosts before changing data for exception safety.
+ for host in hosts:
+ rpc_utils.check_modify_host_locking(host, update_data)
for host in hosts:
host.update_object(update_data)