Skip to content

Commit

Permalink
Merge pull request #590 from Ouranosinc/register-update-svc-type
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault authored Oct 3, 2023
2 parents bc8c146 + 027d107 commit 6cf49b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~
Expand Down
9 changes: 8 additions & 1 deletion magpie/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6cf49b1

Please sign in to comment.