Browse Source

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
changes/46/434846/1
Alex Kavanagh 2 years ago
parent
commit
ceb612a49d
2 changed files with 12 additions and 4 deletions
  1. 6
    2
      provides.py
  2. 6
    2
      requires.py

+ 6
- 2
provides.py View File

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

+ 6
- 2
requires.py View File

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

Loading…
Cancel
Save