openvstorage / framework

The Framework is a set of components and tools which brings the user an interface (GUI / API) to setup, extend and manage an Open vStorage platform.
Other
27 stars 23 forks source link

ignore nsm cluster if already present in the abm #1632

Open jeroenmaelbrancke opened 7 years ago

jeroenmaelbrancke commented 7 years ago

Readding a backend (delete, add) with external Arakoons ends up with errors:

May 09 11:44:04 stor-221-3 celery[14181]:   File "/opt/OpenvStorage/ovs/lib/alba.py", line 536, in _alba_arakoon_checkup
May 09 11:44:04 stor-221-3 celery[14181]:     ip=clients.keys()[0])
May 09 11:44:04 stor-221-3 celery[14181]:   File "/opt/OpenvStorage/ovs/lib/alba.py", line 1105, in _register_nsm
May 09 11:44:04 stor-221-3 celery[14181]:     client=SSHClient(endpoint=ip))
May 09 11:44:04 stor-221-3 celery[14181]:   File "/opt/OpenvStorage/ovs/extensions/plugins/albacli.py", line 139, in run
May 09 11:44:04 stor-221-3 celery[14181]:     raise AlbaError(output['error']['message'], output['error']['exception_code'])
May 09 11:44:04 stor-221-3 celery[14181]: AlbaError: Albamgr exception(Albamgr_protocol.Protocol.Error.Nsm_host_already_exists,Albamgr_protocol.Protocol.Error.Nsm_host_already_exists)

You can fix this with checking the list-nsm-hosts on the abm and if not present register else return

    @staticmethod
    def _register_nsm(abm_name, nsm_name, ip):
        """
        Register the NSM service to the cluster
        :param abm_name: Name of the ABM cluster
        :type abm_name: str
        :param nsm_name: Name of the NSM cluster
        :type nsm_name: str
        :param ip: IP of node in the cluster to register
        :type ip: str
        :return: None
        """
        nsm_config_file = Configuration.get_configuration_path(ArakoonClusterConfig.CONFIG_KEY.format(nsm_name))
        abm_config_file = Configuration.get_configuration_path(ArakoonClusterConfig.CONFIG_KEY.format(abm_name))
        for host in AlbaCLI.run(command='list-nsm-hosts', config=abm_config_file, client=SSHClient(ip)):
            if host['cluster_id'] == nsm_name:
                return
        AlbaCLI.run(command='add-nsm-host',
                    config=abm_config_file,
                    extra_params=[nsm_config_file],
                    client=SSHClient(endpoint=ip))
khenderick commented 7 years ago

I'd rather not "fix" this, as our code should be in charge of registering nsm clusters with the abm once required. External clusters can be set up separately, and there are API calls to start using an NSM on a given ABM, and the framework will do all required actions.

khenderick commented 7 years ago

After some discussions with @wimpers, @jeroenmaelbrancke, @domsj just re-throw the error, but slightly more readable.

In the future, we might want to implement sth where NSMs can be removed again, and we can validate whether an NSM is already in use by some ABM, so we can be a bit smarter here.