amazon-web-servicesamazon-ec2starcluster

Detect if I am in master from inside of starcluster plugin


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.


Solution

  • given plugins on_add_node signature

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

    You can call

    node.is_master()