diff options
author | Lance Bragstad <lbragstad@gmail.com> | 2017-07-25 17:03:55 +0000 |
---|---|---|
committer | Lance Bragstad <lbragstad@gmail.com> | 2017-08-09 14:45:58 +0000 |
commit | 63124f703a81074793360c1b91711b6ee5a76196 (patch) | |
tree | 65d874a5b4d3e6b9fcbc9c3129c6b3885643377d | |
parent | 9fccd38d1b177664c64bbf987a8c31d06d7cfc60 (diff) | |
download | keystone-63124f703a81074793360c1b91711b6ee5a76196.tar.gz |
Cache list projects and domains for user
Listing projects and domains for a user based on their role
assignments was noted as being really slow, especially when users
have a lot of assignments. This commit implements caching to mitigate
the issue while we continue to investigate ways to speed up the
assignment API.
Change-Id: I72e398c65f01aa4f9a37f817d184a13ed01089ce
Closes-Bug: 1700852
-rw-r--r-- | keystone/assignment/core.py | 9 | ||||
-rw-r--r-- | keystone/resource/core.py | 5 | ||||
-rw-r--r-- | releasenotes/notes/bug-1700852-de775d0eb2ddfdd1.yaml | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/keystone/assignment/core.py b/keystone/assignment/core.py index 6db4d3209..c9a84e9b5 100644 --- a/keystone/assignment/core.py +++ b/keystone/assignment/core.py @@ -223,7 +223,15 @@ class Manager(manager.Manager): # TODO(henry-nash): We might want to consider list limiting this at some # point in the future. + @MEMOIZE_COMPUTED_ASSIGNMENTS def list_projects_for_user(self, user_id): + # FIXME(lbragstad): Without the use of caching, listing effective role + # assignments is slow, especially with large data set (lots of users + # with multiple role assignments). This should serve as a marker in + # case we have the opportunity to come back and optimize this code so + # that it can be performant without having a hard dependency on + # caching. Please see https://bugs.launchpad.net/keystone/+bug/1700852 + # for more details. assignment_list = self.list_role_assignments( user_id=user_id, effective=True) # Use set() to process the list to remove any duplicates @@ -233,6 +241,7 @@ class Manager(manager.Manager): # TODO(henry-nash): We might want to consider list limiting this at some # point in the future. + @MEMOIZE_COMPUTED_ASSIGNMENTS def list_domains_for_user(self, user_id): assignment_list = self.list_role_assignments( user_id=user_id, effective=True) diff --git a/keystone/resource/core.py b/keystone/resource/core.py index 322d4ab4a..1f7423eae 100644 --- a/keystone/resource/core.py +++ b/keystone/resource/core.py @@ -332,6 +332,11 @@ class Manager(manager.Manager): notifications.Audit.disabled(self._PROJECT, project_id, public=False) + # Drop the computed assignments if the project is being disabled. + # This ensures an accurate list of projects is returned when + # listing projects/domains for a user based on role assignments. + assignment.COMPUTED_ASSIGNMENTS_REGION.invalidate() + if cascade: self._only_allow_enabled_to_update_cascade(project, original_project) diff --git a/releasenotes/notes/bug-1700852-de775d0eb2ddfdd1.yaml b/releasenotes/notes/bug-1700852-de775d0eb2ddfdd1.yaml new file mode 100644 index 000000000..903b1e934 --- /dev/null +++ b/releasenotes/notes/bug-1700852-de775d0eb2ddfdd1.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + [`bug 1700852 <https://bugs.launchpad.net/keystone/+bug/1700852>`_] + Keystone now supports caching of the `GET|HEAD + /v3/users/{user_id}/projects` API in an effort to improve performance. |