Further fix to OpenStackAPIRelationAdapters
The existing method of using a property to lazily load the cluster relation adapter permanently changes the class to include that as a cluster property. This means that a future (in the same hook execution) instantiation of the class would include that property, which means that 'real' cluster adapter could not be used. Sadly, this was happening with the manila charm, and possibly others. This patch changes it from a lazily loaded property, to a simple attribute. Change-Id: I704f362e0dd845ff00d0f0470b0235a4dead5f9f Closes-Bug: #1981736
This commit is contained in:
parent
c924762a9c
commit
581300632b
@ -1359,20 +1359,11 @@ class OpenStackAPIRelationAdapters(OpenStackRelationAdapters):
|
|||||||
options=options,
|
options=options,
|
||||||
options_instance=options_instance,
|
options_instance=options_instance,
|
||||||
charm_instance=charm_instance)
|
charm_instance=charm_instance)
|
||||||
self._resolved_cluster = None
|
|
||||||
if 'cluster' not in self._relations:
|
if 'cluster' not in self._relations:
|
||||||
# cluster has not been passed through already, so try to resolve it
|
# cluster has not been passed through already, so try to resolve it
|
||||||
# automatically when it is accessed.
|
# automatically.
|
||||||
# add a property for the cluster to resolve it
|
|
||||||
self._relations.add('cluster')
|
self._relations.add('cluster')
|
||||||
setattr(self.__class__, 'cluster',
|
setattr(self, 'cluster', self._resolve_cluster())
|
||||||
property(lambda x: x._cluster()))
|
|
||||||
|
|
||||||
def _cluster(self):
|
|
||||||
"""The cluster relations is auto added onto adapters instance"""
|
|
||||||
if not self._resolved_cluster:
|
|
||||||
self._resolved_cluster = self._resolve_cluster()
|
|
||||||
return self._resolved_cluster
|
|
||||||
|
|
||||||
def _resolve_cluster(self):
|
def _resolve_cluster(self):
|
||||||
""" Resolve what the cluster adapter is.
|
""" Resolve what the cluster adapter is.
|
||||||
|
Loading…
Reference in New Issue
Block a user