[autotest] Fix couple issues in host history/label collection.
Issue was introduced in CL 242701. There is no unittest to catch such issue
because the data needs to be retrieved from a live ES instance. Some manual
test could have helped though.
BUG=None
TEST=edit local shadow config to target to production metadb
CROS/ES_HOST and CLIENT/metadata_index
run some commands:
./collect_host_stats.py --span 24
./host_history.py -l 24 --hosts chromeos1-row2-rack4-host2 -v
Change-Id: If5c6409c0b4479c7e6cfd8575099c2e704d37c28
Reviewed-on: https://chromium-review.googlesource.com/251570
Commit-Queue: Dan Shi <dshi@chromium.org>
Trybot-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Gabe Black <gabeblack@chromium.org>
diff --git a/site_utils/host_label_utils.py b/site_utils/host_label_utils.py
index 2d6806d..d30d1b8 100755
--- a/site_utils/host_label_utils.py
+++ b/site_utils/host_label_utils.py
@@ -72,7 +72,7 @@
if results.total == 0:
logging.error('No label information was logged before %s.', t_end_str)
return
- time_index = results['time_index'][0]
+ time_index = results.hits[0]['time_index']
logging.info('Host labels were recorded at %s',
time_utils.epoch_time_to_date_string(time_index))