Config: Make person and project services configurable per tenant#475
Config: Make person and project services configurable per tenant#475ValentinFutterer wants to merge 2 commits intonextfrom
Conversation
1e95aec to
cffbc7e
Compare
docker/docker-compose.postgres.yaml
Outdated
| # Since DAMAP containers are publicly available on GitHub packages one can | ||
| # just pull the latest container image. | ||
| image: ghcr.io/damap-org/damap-backend:next | ||
| #image: ghcr.io/damap-org/damap-backend:next |
There was a problem hiding this comment.
leftovers from dev? this shouldn't be commented out
There was a problem hiding this comment.
Yes good catch
docker/tenants.yaml
Outdated
| tenants: ['tenant_1', 'tenant_2'] | ||
| damap: | ||
| tenants: | ||
| tenants: ['tenant_1', 'tenant_2'] |
There was a problem hiding this comment.
this duplicate key naming can cause confusion. Maybe rename it to tenants.items?
There was a problem hiding this comment.
i renamed it to tenant-list
|
Solid effort on a first glance.
|
cffbc7e to
a580dea
Compare
Yes for sure, as I wrote in my internal message, I am pretty sure that the Helm Chart doesnt work correctly anymore. I tried to fix as much as possible, but I only had limited time and knowledge, so I have to ask you to fix my mess for me 😃
Its a breaking change, but v5.0.0 is going to be breaking anyway. Now its just even more so. We already renamed many config properties and added new ones, now they also need to prepend the
What are you referring to with passing as YAML. I thought we passed the list as JSON. But dont worry, the list will realistically never grow beyond 5 services (and even that is hyperbolical). In Almost every case, 3 will be the maxium and most will have two. |
Description
Refactoring / Config
What does this PR do?
Dont be scared by the amount of files touched, most are just adjustments made after config changes.
The heart of the PR is a change to config that allows for configuring persons and project services (and fields / title) per tenant and not once for the whole application. To do this, I grouped all config fields in the application.yaml under "tenant-aware" (if you have better naming suggestions, do tell). Then I used Quarkus
@ConfigMappingto load the whole config as one config object. This allows for switching config objects by checking tenant ID at runtime.@ConfigPropertywould not work, since they are loaded statically at runtime.Multitenancy configuraton has now changed. You need to supply the tenants under the
tenantskey and supply ALL tenant-aware configs per tenant. These are then loaded and switched between dynamically per request.Sadly, Quarkus has some strict opinions on how to load these configs, so I had to axe all environment variables that could load configs via json. This wasnt an easy decision, but Quarkus gotta be Quarkus. It actually parsed the json correctly, but then the validator complains...
Anyways this has lead to some more changes. The person services list now has to passed like this as env variables:
The
_0__is the list index, so for a second list element, you would increment to_1__.DAMAP_TENANT_AWARE_ELSEVIER_PURE_CONTRIBUTOR_ROLE_CLASSIFICATIONSused to be a map with the pure role/dk/atira/pure/memberas key. Since we cnanot parse json anymore, I tried to load it as env variables, but failed. Since the/are turned to_as env variables, but_could also be [ or ] or ., Quarkus cannot go from the env variable to the correct config element. Therefore I had to do an ugly workaround and also turn it into a list like this:Please check in the code if the list elements are used correctly.
All of this of course broke the tests, since now they had to load the config differently, so I did a bunch of refactoring there.
Also, since we switch dynamically between tenants, I couldnt use a static Pure Client anymore. So I reused the PureApiFactory to generate dynamic PureClients per HTTP request based on the calling tenant + some caching to make the generation efficient. Please check this whole process also by using the console. E.g. give some bogus URL unique for each tenant and then check the error messages in the console.
I also added a mode for disabling project services, since some Unis wont connect any. The frontend gets the info in the config, but cant use it yet. (Will create an issue for that).
Documentation will follow on the Website at a later date.
I tried to update the Helm Chart too but I ran out of time. I did some stuff, but I am sure there is somehting wrong / missing. E.g. the loading of person services. Sorry in advance.
Breaking changes
Configstuff, very much breaking
Code review focus
Naming, did everything make sense. Does Pure still work? Testing on Kubernetes please.
closes GH-472