Detect if I am in master from inside of starcluster plugin

25 views Asked by At

When you try to add a node to an existing cluster of Starcluster, some plugins can fail depending if you are in master or secondary node.

If your plugin has something like:

for node in nodes:
    do something...

when you add a node with

starcluster addnode myexistingcluster

the previous form does not works.

So how would try to differentiate the plugin's operations for master and secondaries nodes.

How can I check if I am in the master from inside the plugin? I tried with the index of nodes list but does not works.

1

There are 1 answers

0
Finch_Powers On BEST ANSWER

given plugins on_add_node signature

def on_add_node(self, node, nodes, master, user, user_shell, volumes):

You can call

node.is_master()