Fix missing "is None" for check_metrics in grafana

One condition misses "is None" and so raises KeyError, so
fix this place.

Change-Id: Idf28fef97a261c12792b65cb1c5624368d3f8646
This commit is contained in:
Peter Razumovsky 2018-10-25 19:58:39 +04:00
parent a8d3ed895d
commit 536a69f1f4

View File

@ -60,11 +60,12 @@ class GrafanaService(service.Service):
self._spec["grafana"]["password"]))
result = resp.json()
LOG.debug("Grafana response code: %s" % resp.status_code)
is_result = result.get("data") or len(result["data"]["result"]) < 1
if is_result and i + 1 >= retries_total:
no_result = (result.get("data") is None or
len(result["data"]["result"]) < 1)
if no_result and i + 1 >= retries_total:
LOG.debug("No instance metrics found in Grafana")
return False
elif is_result:
elif no_result:
i += 1
commonutils.interruptable_sleep(sleep_time)
else: