Repository navigation
[SCIM 4/4]: Draw the rest of the owl - #9276
Conversation
The majority of this PR fills out the CrdbScimProviderStore implementation that the scim2-rs crate's Provider object will use to implement SCIM where CRDB is the durable store for users and groups, and adds a boat load of integration tests. The notion of a silo user being "active" or not has also been added to support users being deactivated by the SCIM client. Non-SCIM silo users should not be affected.
| for user in users { | ||
| let groups = self | ||
| .get_user_groups_for_user_in_txn(conn, user.identity.id.into()) | ||
| .await?; | ||
|
|
||
| let SiloUser::Scim(user) = user.into() else { | ||
| // With the user provision type filter, this should never be | ||
| // another type. | ||
| unreachable!(); | ||
| }; | ||
|
|
||
| returned_users.push(convert_to_scim_user(user, groups)); | ||
| } |
There was a problem hiding this comment.
This should be able to be done in one query with the list of user IDs
There was a problem hiding this comment.
Since this is classified as a performance optimization I am inclined to say that we should punt on the addition of a follow on PR until after R17 is cut. The main reasoning behind this is all of the testing done so far by me, James, Angela, and Jay has been against the current implementation and the window for R17 is closing asap.
I would like to give the perf optimaztion more time to soak as we already know some of this code will have to change as we have to fix oxidecomputer/scim2-rs#7 relatively soon anyways.
There was a problem hiding this comment.
I am concerned about running 1000+ queries in a single GET request — has that been exercised?
There was a problem hiding this comment.
Using this gist we compared the time to list users before and after my changes and it was 75-80% faster after the optimization, at least on my machine. However both response times were tolerable — the slower one was 260-290ms. The fast one was 62-65ms. On @papertigers machine the slow version was more like 800-900ms.
There was a problem hiding this comment.
I modified one of the integration tests to do the following:
- Create 1000 users
- Create a group with those 1000 users as member
- Captured the time it takes to hit the GET
/Usersendpoint
On my machine over multiple runs it seemed to take ~700-900ms.
Again, I think this should be improved upon and I suspect many optimizations can be made here. Regardless I think some of this code will need to be modified anyways to support pagination.
Thoughts on having this go in as is?
There was a problem hiding this comment.
We probably want to get this landed as is and follow up with tuning work afterwards to unblock customers waiting to validate their integration workflow.
There was a problem hiding this comment.
Yeah, if it's tolerable for now and considered a starting point anyway then that's fine.
…ed (#11713) In working on a console PR (oxidecomputer/console#3211) I discovered that #8605 was still open. (#9276 handled deletion of role assignments for SCIM-managed users / groups, but not for local ones). This PR adds a method that handles the deletion of role assignments for locally-managed users and groups, and calls it when the user / group is deleted. It also deletes silo-scoped role assignments when a silo is deleted. Note: there is no method to delete groups locally, but deleting a silo without addressing the roles would leave some orphaned rows, so this code cleans up the roles during the silo deletion process. "But wait!", I hear you say, "what about the orphaned rows from users that have already been deleted from the silo? Isn't that what prompted #8605 in the first place?" Good question. That is outside the scope of this PR, but the robot suggests there's a migration from before that covers similar territory: `schema/crdb/cleanup-orphaned-subnet-pool-silo-links` (version 248): ```sql SET LOCAL disallow_full_table_scans = off; DELETE FROM omicron.public.subnet_pool_silo_link WHERE subnet_pool_id NOT IN ( SELECT id FROM omicron.public.subnet_pool WHERE time_deleted IS NULL ); ``` So that's something we can talk through separately. Unrelated, but I also came across some old uncalled code in `silo_group_delete`; this PR removes that method as well. #8605 will still be open after this merges. We will need to clean up the leftover rows, per the note above, to fully close that issue.
The majority of this PR fills out the CrdbScimProviderStore implementation that the scim2-rs crate's Provider object will use to implement SCIM where CRDB is the durable store for users and groups, and adds a boat load of integration tests.
The notion of a silo user being "active" or not has also been added to support users being deactivated by the SCIM client. Non-SCIM silo users should not be affected.