Work around a strange bug wit reactive/juju 1.25.x

There is a strange bug where, randomly, and only with Juju 1.25.9 or 10,
the conversation for a relation doesn't exist, even though the relation
has been made.  This is a workaround that appears to have no impact on
using charm's functionality.

The clear_changed() methods are to remove a {relation-name}.changed flag
that gets set when the data on the relation changes.  However, not being
able to clear it, simply means that it will still be set the next time
the charm runs which might mean that some handlers run again.  This
shouldn't be a problem as, by design, reactive handlers MUST be
idempotent.

Change-Id: I26ec730d88e04fb3942d0240bf4eba6c6642a168
Related-Bug: 1663633
This commit is contained in:
Alex Kavanagh 2017-02-16 11:37:25 +00:00
parent 4c8d468393
commit ceb612a49d
2 changed files with 12 additions and 4 deletions

View File

@ -93,8 +93,12 @@ class ManilaPluginProvides(reactive.RelationBase):
def clear_changed(self):
"""Provide a convenient method to clear the .changed relation"""
conversation = self.conversation()
conversation.remove_state(self.states.changed)
try:
self.remove_state(self.states.changed)
except ValueError:
# work around Juju 1.25.x error where it can't find the scope for
# the interface (randomly) - Bug #1663633
pass
@property
def name(self):

View File

@ -120,8 +120,12 @@ class ManilaPluginRequires(reactive.RelationBase):
def clear_changed(self):
"""Provide a convenient method to clear the .changed relation"""
conversation = self.conversation()
conversation.remove_state(self.states.changed)
try:
self.remove_state(self.states.changed)
except ValueError:
# this works around a Juju 1.25.x bug where it can't find the right
# scoped conversation - Bug #1663633
pass
def set_authentication_data(self, value, name=None):
"""Set the authentication data to the plugin charm. This is to enable