[autotest] Endpoints for syncing jobs and hqes back to master
The status of jobs that were completed on a shard should be visible
in the master AFE, so a human can easily see which jobs have been run in one
central place.
This adds the functionality to the AFE to retrieve newer versions of
jobs and hqes from shards.
BUG=None
DEPLOY=apache, afe
TEST=Ran Suites
Change-Id: I04c3401921a3f54bae6070639af805904952bf6a
Reviewed-on: https://chromium-review.googlesource.com/213901
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Jakob Jülich <jakobjuelich@chromium.org>
Tested-by: Jakob Jülich <jakobjuelich@chromium.org>
diff --git a/frontend/afe/models.py b/frontend/afe/models.py
index 5eea6d8..0b03110 100644
--- a/frontend/afe/models.py
+++ b/frontend/afe/models.py
@@ -16,10 +16,10 @@
from autotest_lib.frontend.afe import model_logic, model_attributes
from autotest_lib.frontend.afe import rdb_model_extensions
from autotest_lib.frontend import settings, thread_local
-from autotest_lib.client.common_lib import enum, host_protections, global_config
+from autotest_lib.client.common_lib import enum, error, host_protections
+from autotest_lib.client.common_lib import global_config
from autotest_lib.client.common_lib import host_queue_entry_states
-from autotest_lib.client.common_lib import control_data, priorities
-from autotest_lib.client.common_lib import decorators
+from autotest_lib.client.common_lib import control_data, priorities, decorators
# job options and user preferences
DEFAULT_REBOOT_BEFORE = model_attributes.RebootBefore.IF_DIRTY
@@ -1100,6 +1100,14 @@
self.shard = Shard.deserialize(data)
+ def sanity_check_update_from_shard(self, shard, updated_serialized):
+ if not self.shard_id == shard.id:
+ raise error.UnallowedRecordsSentToMaster(
+ 'Job id=%s is assigned to shard (%s). Cannot update it with %s '
+ 'from shard %s.' % (self.id, self.shard_id, updated_serialized,
+ shard.id))
+
+
# TIMEOUT is deprecated.
DEFAULT_TIMEOUT = global_config.global_config.get_config_value(
'AUTOTEST_WEB', 'job_timeout_default', default=24)
@@ -1426,6 +1434,14 @@
self.meta_host = Label.deserialize(data)
+ def sanity_check_update_from_shard(self, shard, updated_serialized,
+ job_ids_sent):
+ if self.job_id not in job_ids_sent:
+ raise error.UnallowedRecordsSentToMaster(
+ 'Sent HostQueueEntry without corresponding '
+ 'job entry: %s' % updated_serialized)
+
+
Status = host_queue_entry_states.Status
ACTIVE_STATUSES = host_queue_entry_states.ACTIVE_STATUSES
COMPLETE_STATUSES = host_queue_entry_states.COMPLETE_STATUSES