Check if instance_id is not None

get_label returns instance_id that can be None [1].
It could lead to the exception [2]. The patch will
resolve it.

[1] https://github.com/openstack/vitrage/blob/master/vitrage/datasources/prometheus/properties.py#L56
[2] http://paste.openstack.org/show/738265/

Change-Id: Ic914832fde53cd904bfc0e3313348d3025c69ca0
This commit is contained in:
Kien Nguyen 2018-12-24 16:06:01 +07:00
parent f617f65a1b
commit d7d4188d06

View File

@ -148,6 +148,7 @@ class PrometheusDriver(AlarmDriverBase):
alarm[DSProps.EVENT_TYPE] = event_type
alarm[PProps.STATUS] = details[PProps.STATUS]
instance_id = get_label(alarm, PLabels.INSTANCE)
if instance_id is not None:
if ':' in instance_id:
instance_id = instance_id[:instance_id.index(':')]