Done
Details
Assignee
Julian LadischJulian LadischReporter
Taras SpashchenkoTaras SpashchenkoPriority
TBDDevelopment Team
Core: PlatformRelease
Ramsons (R2 2024)RCA Group
Implementation coding issueTestRail: Cases
Open TestRail: CasesTestRail: Runs
Open TestRail: Runs
Details
Details
Assignee
Julian Ladisch
Julian LadischReporter
Taras Spashchenko
Taras SpashchenkoPriority
Development Team
Core: Platform
Release
Ramsons (R2 2024)
RCA Group
Implementation coding issue
TestRail: Cases
Open TestRail: Cases
TestRail: Runs
Open TestRail: Runs
Created October 4, 2024 at 9:31 AM
Updated October 11, 2024 at 3:05 PM
Resolved October 11, 2024 at 3:05 PM
We faced an issue related to folio permission renaming and its support in Okapi + mod-permissions.
We conducted the following spike in order to assess the permissions' renaming transparency for the end users.
Create a fresh environment with FOLIO, using old permissions.
Create a user and assign permissions to that user.
There should be a permission set containing permission from the backend module that will be renamed.
There should be a permission set containing another permission set that will be renamed
There should be a permission set that will be renamed
Create snapshots for tables in the mod-permissions schema (permissions, permissions_users);
Save a response from the "_self" request for comparison.
Deploy back-end modules from the branches with the renamed permissions. Do not enable modules for a tenant (Jenkins job).
Merge UI changes into master branches. The UI module descriptors will be generated.
Manually register generated UI module descriptors in Okapi.
Manually enable new versions of modules for a tenant.
Check user permission and availability of UI controls.
Check the response from the "_self" request and compare it to the previous one.
Compare the content of the tables in the mod-permissions schema.
The result is disappointing.Okapi does not support the correct migration of UI permissions.
Furthermore, after such a migration, the set of permissions for each individual user changes randomly. Permissions that have been renamed disappear from the list of those assigned to the user.We reproduced this in two different environments.
For the sake of simplicity, we selected two modules ui-oai-pmh and mod-oai-pmh.
We created a user and assigned the following permissions:
["ui-oai-pmh.view", "ui-oai-pmh.edit", "ui-oai-pmh.logs"]
Then we did the following permission renaming:
on the back-end (this is just for testing purposes, there's no logic behind this renaming)
"oai-pmh.sets.item.put" -> "oai-pmh.settings.item.put"
"oai-pmh.request-metadata.logs.item.get" -> "oai-pmh.metadata.logs.item.get"
on the front-end
"ui-oai-pmh.view" -> "ui-oai-pmh.settings.view"
"ui-oai-pmh.edit" -> "ui-oai-pmh.settings.edit"
"ui-oai-pmh.logs" -> "ui-oai-pmh.settings.logs.view"
After the modules' updates the set of the permissions assigned to the user was:
["ui-oai-pmh.settings.logs.view"]
We did the same on another env, and as a result, we got this set of permissions assigned to the user after modules' updates:
["ui-oai-pmh.settings.edit"]
The expected result is that the user should have the following set of permissions assigned:
["ui-oai-pmh.settings.view", “ui-oai-pmh.settings.edit", “ui-oai-pmh.settings.logs.view"]
We did testing in Rancher Dev env and on the sprint testing Rancher env.
We used artifacts built from the master branches to create environments for all FOLIO modules (SNAPSHOT versions)
Cause
A simplified version of the code is this:
If there are multiple permission replacements for one user the
GenericCompositeFuture.all
allows Vert.x to run them in parallel.Therefore all
lookupPermsUsersById
SELECTs read the old permission set of the user.Due to
GenericCompositeFuture.all
all SELECTs have completed when the UPDATEs start.Each
update
adds only one new permission, and eachupdate
overwrites the added permission of the previousupdate
s.The complete permission migration runs on a single transaction to allow for roll-back in case of failure. Therefore PostgreSQL doesn’t reject the UPDATE based on an outdated SELECT.
Solution
Replace
GenericCompositeFuture.all
with sequential future.compose. Do this also for otherGenericCompositeFuture.all
in the TenantPermsAPI.This doesn’t cause any performance issue because all SQL queries run on a single transaction and therefore cannot run in parallel, even when using
GenericCompositeFuture.all
.Consider merging the SELECT and the following UPDATE into a single UPDATE when it makes the code easier.