From 45cf162c8a8e64d304b0b505d8affb331e65b595 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 14 Feb 2022 11:10:00 +0000 Subject: [PATCH] Check relation exists in ovsdb lib --- .../lib/charms/sunbeam_ovn_central_operator/v0/ovsdb.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/charms/ovn-central-k8s/lib/charms/sunbeam_ovn_central_operator/v0/ovsdb.py b/charms/ovn-central-k8s/lib/charms/sunbeam_ovn_central_operator/v0/ovsdb.py index ec16695a..26e9903e 100644 --- a/charms/ovn-central-k8s/lib/charms/sunbeam_ovn_central_operator/v0/ovsdb.py +++ b/charms/ovn-central-k8s/lib/charms/sunbeam_ovn_central_operator/v0/ovsdb.py @@ -37,7 +37,7 @@ LIBAPI = 0 # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 1 +LIBPATCH = 2 # TODO: add your code here! Happy coding! @@ -122,8 +122,9 @@ class OVSDBCMSRequires(Object): """Retrieve value for key from all related units.""" values = [] relation = self.framework.model.get_relation(self.relation_name) - for unit in relation.units: - values.append(relation.data[unit].get(key)) + if relation: + for unit in relation.units: + values.append(relation.data[unit].get(key)) return values