[autotest] Exclude jobs that don't have HQE in heartbeat response
For a heartbeat response, a master included jobs
that don't have HQEs. HQE records can be accidently removed.
This CL makes autotest tolerable to such an accident.
BUG=chromium:479766
DEPLOY=apache
TEST=puppylab
Change-Id: Id1c75c9cd869e91552749f8fc7ea3bb14b810bb1
Reviewed-on: https://chromium-review.googlesource.com/267290
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Mungyung Ryu <mkryu@google.com>
Tested-by: Mungyung Ryu <mkryu@google.com>
diff --git a/frontend/afe/models.py b/frontend/afe/models.py
index 21db749..27ae9da 100644
--- a/frontend/afe/models.py
+++ b/frontend/afe/models.py
@@ -1506,7 +1506,12 @@
# If this changes or they are triggered manually, this applies:
# Jobs may be returned more than once by concurrent calls of this
# function, as there is a race condition between SELECT and UPDATE.
- query = Job.objects.filter(dependency_labels=shard.labels.all())
+ query = Job.objects.filter(
+ dependency_labels=shard.labels.all(),
+ # If an HQE associated with a job is removed in some reasons,
+ # such jobs should be excluded. Refer crbug.com/479766
+ hostqueueentry__isnull=False
+ )
query = cls._add_filters_for_shard_assignment(query, known_ids)
job_ids = set(query.distinct().values_list('pk', flat=True))