Zookeeper charm zkpeer-relation-changed issue.

José Pekkarinen jose.pekkarinen at canonical.com
Fri Feb 23 14:53:42 UTC 2018


	Hi list,

	I'm trying to add a zkpeer-relation-changed hook to the zookeeper charm. I 
wrote some changes working in an out of date version, and I'm rewriting the 
change to be upstreamable. the new version of the change looks like:

github.com/apache/bigtop:
diff --git a/bigtop-packages/src/charm/zookeeper/layer-zookeeper/reactive/
zookeeper.py b/bigtop-packages/src/charm/zookeeper/layer-zookeeper/reactive/
zookeeper.py
index a4c7773b..51c7c75a 100644
--- a/bigtop-packages/src/charm/zookeeper/layer-zookeeper/reactive/
zookeeper.py
+++ b/bigtop-packages/src/charm/zookeeper/layer-zookeeper/reactive/
zookeeper.py
@@ -196,6 +196,12 @@ def check_cluster_departed(zkpeer, zkpeer_departed):
     check_cluster(zkpeer)
 
 
+ at when('zookeeper.started', 'leadership.is_leader', 'zkpeer.changed')
+def check_cluster_changed(zkpeer):
+    check_cluster(zkpeer)
+    zkpeer.dismiss_changed()
+
+
 @when('leadership.changed.restart_queue', 'zkpeer.joined')
 def restart_for_quorum(zkpeer):
     '''

github.com/juju-solutions/interface-zookeeper-quorum
diff --git a/peers.py b/peers.py
index 41184509..018551d2 100644
--- a/peers.py
+++ b/peers.py
@@ -30,6 +30,12 @@ class ZookeeperPeers(RelationBase):
         conv.remove_state('{relation_name}.joined')
         conv.set_state('{relation_name}.departed')
 
+
+    @hook('{peers:zookeeper-quorum}-relation-changed')
+    def changed(self):
+        conv = self.conversation()
+        conv.set_state('{relation_name}.changed')
+
     def dismiss_departed(self):
         for conv in self.conversations():
             conv.remove_state('{relation_name}.departed')
@@ -38,6 +44,10 @@ class ZookeeperPeers(RelationBase):
         for conv in self.conversations():
             conv.remove_state('{relation_name}.joined')
 
+    def dismiss_changed(self):
+        for conv in self.conversations():
+            conv.remove_state('{relation_name}.changed')
+
     def get_nodes(self):
         nodes = []
         for conv in self.conversations():

	The issue I get when executing the hook is:

# juju-run unit-zookeeper-0 hooks/zkpeer-relation-changed
Running reactive_handler_main for cuda.sh (test)
Nothing to invoke
End reactive_handler_main (test)
Traceback (most recent call last):
  File "hooks/zkpeer-relation-changed", line 19, in <module>
    main()
  File "/usr/local/lib/python3.5/dist-packages/charms/reactive/__init__.py", 
line 72, in main
    bus.dispatch(restricted=restricted_mode)
  File "/usr/local/lib/python3.5/dist-packages/charms/reactive/bus.py", line 
367, in dispatch
    _invoke(hook_handlers)
  File "/usr/local/lib/python3.5/dist-packages/charms/reactive/bus.py", line 
351, in _invoke
    handler.invoke()
  File "/usr/local/lib/python3.5/dist-packages/charms/reactive/bus.py", line 
173, in invoke
    self._action(*args)
TypeError: changed() missing 1 required positional argument: 'self'

	Which I presume it comes by the definition of check_cluster_changed, on the 
number of parameters, but I'm not that experienced with reactive charms to 
know. Can anyone shoot some thoughts on what the issue may be here?

	Thanks!

	José.



More information about the Bigdata mailing list