Fixing: TypeError: '<' not supported between instances of 'list' and 'str'

The above exception [1] occurs for example [2] when elasticsearch returns data
with more than one zuul_executor as a list.

This is what l#58 is able to sort
[(12.5, '5'), (12.5, '4'), (12.5, '3'), (25.0, '6'), (18.75, '2'), (6.25, '13'), (12.5, '1')]

This  is when it throws exception
[(8.13953488372093, 'ze06.opendev.org'),
(12.790697674418604, 'ze10.opendev.org'),
(5.813953488372093, 'ze05.opendev.org'),
(8.13953488372093, 'ze01.opendev.org'),
(16.27906976744186, 'ze04.opendev.org'),
(4.651162790697675, 'ze03.opendev.org'),
(3.488372093023256, 'ze02.opendev.org'),
(4.651162790697675, 'ze08.opendev.org'),
(12.790697674418604, 'ze09.opendev.org'),
(20.930232558139537, 'ze12.opendev.org'),
(1.1627906976744187, 'ze11.opendev.org'),
(1.1627906976744187, ['ze12.opendev.org', 'ze11.opendev.org'])]

[1] https://0050cb9fd8118437e3e0-3c2a18acb5109e625907972e3aa6a592.ssl.cf5.rackcdn.com/790065/7/check/openstack-tox-py38/4968a73/tox/test_results/1449136.yaml.log
[2] https://review.opendev.org/c/openstack/tripleo-ci-health-queries/+/787569/6/output/elastic-recheck/1449136.yaml

Change-Id: Ie559d5764d9f68420119a7f9608389f0745a9c02
This commit is contained in:
frenzyfriday 2021-05-19 21:40:19 +02:00
parent 668269bbcd
commit 01b6b8299b

View File

@ -57,7 +57,7 @@ def analyze_attributes(attributes):
# sort by hit percentage descending, and then by value ascending
analysis[attribute] = sorted(
analysis[attribute],
key=lambda x: (1 - x[0], x[1]))
key=lambda x: (1 - x[0], str(x[1])))
return analysis