From a0b36260080737f8fcc994ee40e04bc3b7a2773b Mon Sep 17 00:00:00 2001 From: Jeffrey Devloo Date: Fri, 14 Sep 2018 15:33:28 +0200 Subject: [PATCH 1/2] Registration keys can be generated for all storagerouters during the update --- src/generic/configuration/configuration.py | 21 +++++++++++++++++---- src/services/servicefactory.py | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/generic/configuration/configuration.py b/src/generic/configuration/configuration.py index 37ad444c..fe290080 100644 --- a/src/generic/configuration/configuration.py +++ b/src/generic/configuration/configuration.py @@ -512,18 +512,20 @@ def safely_store(cls, callback, max_retries=20): return return_value @classmethod - def register_usage(cls, component_identifier): - # type: (str) -> List[str] + def register_usage(cls, component_identifier, registration_key=None): + # type: (str, str) -> List[str] """ Registers that the component is using configuration management When sharing the same configuration management for multiple processes, these registrations can be used to determine if the configuration access can be wiped on the node :param component_identifier: Identifier of the component :type component_identifier: str + :param registration_key: Key to register the component under + :type registration_key: str :return: The currently registered users :rtype: List[str] """ - registration_key = cls.get_registration_key() + registration_key = registration_key or cls.get_registration_key() def _register_user_callback(): registered_applications = cls.get(registration_key, default=None) @@ -539,7 +541,18 @@ def get_registration_key(cls): :return: The registration key :rtype: str """ - return COMPONENTS_KEY.format(System.get_my_machine_id()) + return cls.generate_registration_key(System.get_my_machine_id()) + + @classmethod + def generate_registration_key(cls, identifier): + # type: (str) -> str + """ + Generate a registration key with a given identifier + :param identifier: Identifier for the config key + :type identifier: str + :return: + """ + return COMPONENTS_KEY.format(identifier) @classmethod def unregister_usage(cls, component_identifier): diff --git a/src/services/servicefactory.py b/src/services/servicefactory.py index 4eb79717..9640bff1 100644 --- a/src/services/servicefactory.py +++ b/src/services/servicefactory.py @@ -194,7 +194,7 @@ def get_service_update_versions(cls, client, service_name, binary_versions, pack continue pkg_name = version.strip().split('=')[0] running_version = version.strip().split('=')[1] - if (package_name is None or pkg_name == package_name) and running_version is not None: + if (package_name or pkg_name == package_name) and running_version: if LooseVersion(running_version) < binary_versions[pkg_name]: return {'installed': running_version, 'candidate': str(binary_versions[pkg_name])} From 80814ae4c3a97b3c14ff23f5a2ca16fe8a2536d4 Mon Sep 17 00:00:00 2001 From: Jeffrey Devloo Date: Fri, 14 Sep 2018 15:39:38 +0200 Subject: [PATCH 2/2] Package version is optional and should be checked --- src/services/servicefactory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/servicefactory.py b/src/services/servicefactory.py index 9640bff1..a148f780 100644 --- a/src/services/servicefactory.py +++ b/src/services/servicefactory.py @@ -194,7 +194,7 @@ def get_service_update_versions(cls, client, service_name, binary_versions, pack continue pkg_name = version.strip().split('=')[0] running_version = version.strip().split('=')[1] - if (package_name or pkg_name == package_name) and running_version: + if (package_name is None or pkg_name == package_name) and running_version: if LooseVersion(running_version) < binary_versions[pkg_name]: return {'installed': running_version, 'candidate': str(binary_versions[pkg_name])}