Project

General

Profile

Bug #31024

Host show api endpoint is slow for non-admin user

Added by Ondřej Ezr 12 months ago. Updated 11 months ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Inventory
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1667647

Description of problem:
When a non-admin user fetches host details, it takes much more time than for admin user. Something similar like:

https://bugzilla.redhat.com/show_bug.cgi?id=1598855

but just for getting host info, not editing.

When applied upstream patch from bz1598855 to Sat 6.4.1, no improvement in performance was noticed. So it is a separate issue (or not sufficiently general patch covering both scenarios).

Version-Release number of selected component (if applicable):
6.4.1, seen also on 6.3

How reproducible:
100%

Steps to Reproduce:
1. Have a Satellite with some Hosts (I think the count does not matter)
2. Have a non-admin user with all rights but not Admin checkbox.
3. Run:

time curl -X GET -s -k -u nonadmin:password https://$(hostname -f)/api/v2/hosts/529 > /dev/null

4. Select Admin checkbox for the user.
5. Run the curl command again.

Actual results:
3. shows several times higher time than 5.

Expected results:
3. shows comparable time like 5. Some higher value is understandable, but not several times more.

Additional info:

Associated revisions

Revision 1d0e18a1 (diff)
Added by Tomer Brisker 11 months ago

Fixes #31024 - Optimize host taxonomy_conditions (#8101)

Previously, `Taxonomy.expend` was used to get the taxonomies for the
user or the current taxonomy, then all taxonomies were iterated over
to get the subtree ids.
However, when `Taxonomy.current` is `nil`, we already get
all subtree ids since `expend` calls `my_taxonomy` which return the
subtrees already. Instead, we can directly call the
`taxonomy_and_subtree_id` method to get the ids. In the case of admin
user, we don't need a taxonomy condition for `nil` taxonomies as that
should return all taxonomies.
When `Taxonomy.current` is present, we can call the `subtree_ids` method
on it directly without needing to wrap it in an array and iterate over
it.
In the case of `nil` current taxonomies, this can potentially save
hundreds of useless database queries to check subtree ids for all the
taxonomies a user has access to. For example, in my setup every call to
`/api/hosts/$id` triggered 20 queries per taxonomy the user is assigned
to (due to the permission section of the `show.json.rabl` view).

History

#1 Updated by The Foreman Bot 11 months ago

  • Assignee set to Tomer Brisker
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/8101 added

#2 Updated by Tomer Brisker 11 months ago

  • Subject changed from Host detail page load is slow for non-admin user to Host show api endpoint is slow for non-admin user

#3 Updated by The Foreman Bot 11 months ago

  • Fixed in Releases 2.3.0 added

#4 Updated by Tomer Brisker 11 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF