[autotest] get_hosts returns empty result set when given non-existing labels

Previously rpc calls to get_hosts failed when unknown
labels were given. Failing calls were retried by RetryingAFE
and thus the flow got stalled. To fix it, we make
get_host return an empty result set instead of
raising DoesNotExist error on failure. As a result, the call
won't fail and we leave the rpc client to deal with
the empty result. The fix actually lies in
rpc_utils.get_host_query which is called by get_hosts.

BUG=chromium:222927
TEST=Test with a local setup. Confirmed get_hosts won't fail
and won't be retried.
DEPLOY=apache

Change-Id: I87fd1e245b2f898d863a80aff66f61355791aeea
Reviewed-on: https://gerrit.chromium.org/gerrit/47970
Reviewed-by: Alex Miller <milleral@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Fang Deng <fdeng@chromium.org>
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index 353e5f7..0f86a33 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -166,10 +166,12 @@
                             'afe_hosts_labels_exclude_AG.label_id IN (%s)'
                             % atomic_group_label_ids),
                     suffix='_exclude_AG', exclude=True)
-
-    assert 'extra_args' not in filter_data
-    filter_data['extra_args'] = extra_host_filters(multiple_labels)
-    return models.Host.query_objects(filter_data, initial_query=query)
+    try:
+        assert 'extra_args' not in filter_data
+        filter_data['extra_args'] = extra_host_filters(multiple_labels)
+        return models.Host.query_objects(filter_data, initial_query=query)
+    except models.Label.DoesNotExist as e:
+        return models.Host.objects.none()
 
 
 class InconsistencyException(Exception):