diff --git a/CHANGES.rst b/CHANGES.rst index 676e58b1..2154362e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,7 +11,9 @@ Changes Features / Changes ~~~~~~~~~~~~~~~~~~~~~ -* n/a +* Allow startup `Service` registration to update the ``type`` field if a change is detected when loading ``providers`` + configurations. Note that modifying ``type`` of a `Service` with existing `Resource` or `Permission` definitions on + the `Service` itself or any of its children could break the `Magpie` instance if those definitions are not compatible. Bug Fixes ~~~~~~~~~~~~~~~~~~~~~ diff --git a/magpie/register.py b/magpie/register.py index 20870416..7122c6b4 100644 --- a/magpie/register.py +++ b/magpie/register.py @@ -494,8 +494,15 @@ def _magpie_register_services_with_db_session(services_dict, db_session, push_to .format(url=svc.url, svc=svc_name), logger=LOGGER) else: print_log("Service URL update [{url_old}] => [{url_new}] ({svc})" - .format(url_old=svc.url, url_new=svc_new_url, svc=svc_name), logger=LOGGER) + .format(url_old=svc.url, url_new=svc_new_url, svc=svc_name), + logger=LOGGER, level=logging.WARN) svc.url = svc_new_url + if svc.type != svc_type: + print_log("Service type update [{type_old}] => [{type_new}] ({svc}). " + "If children resources/permissions are not compatible, this could break the instance." + .format(type_old=svc.type, type_new=svc_type, svc=svc_name), + logger=LOGGER, level=logging.WARN) + svc.type = svc_type svc.sync_type = svc_sync_type svc.configuration = svc_config elif not force_update and svc_name in existing_services_names: