Page MenuHomePhabricator

Cumin/Openstack: multi-project commands are extremely slow
Closed, DuplicatePublic

Description

On cloud-vps, a command for * or a:all takes around 90 seconds to complete. This results from making several OpenStack calls per project.

It would be good to speed things up for the most-common use case which is a search on every project. The nova API supports an all_tenants argument[0]:

GET /servers  List Servers

<snip>

all_tenants (Optional) query boolean
	

Specify the all_tenants query parameter to list all instances for all projects. By default this is only allowed by administrators. If this parameter is specified without a value, the value defaults to True. If the value is specified, 1, t, true, on, y and yes are treated as True. 0, f, false, off, n and no are treated as False. (They are case-insensitive.)

The endpoint allows the novaobserver to see all projects that it has a role on; because the observer inherits a role on the default domain that means it can effectively query all projects.

The line, above, about 'allowed by administrators' is I believe referring to the nova policy rule "os_compute_api:servers:detail:get_all_tenants" which has a default value of "rule:context_is_admin". In our current deployment we have that policy (and all read-only policies) overridden to "" which means any user can access them.

In the future when we adopt the new 'reader' model for policy enforcement (T276018), that endpoint may be opened up to reader roles by default or we may need to continue to override it; in either case it should be possible to maintain access to that endpoint for the 'observer' role.

Other openstack clouds that don't override their policy files might or might not be able to make use of the all_tenants flag; it would all depend on what service user they assign for Cumin's use. We could add a try/fallback feature for service users that don't have access to the all_tenants option but I'm unclear on how much we want to speculate about rbac models in other unknown clouds.

[0] https://docs.openstack.org/api-ref/compute/?expanded=list-servers-detail#servers-run-an-action-servers-action
[1] https://docs.openstack.org/nova/latest/admin/configuration/samples/policy.yaml.html

Event Timeline

Change 869332 had a related patch set uploaded (by Andrew Bogott; author: Andrew Bogott):

[operations/software/cumin@master] Openstack backend: make use of all_tenants nova api flag

https://gerrit.wikimedia.org/r/869332

@Andrew as I commented on the gerrit patch, would it be possible for you to setup a few temporary Openstack API users with different permissions that I could use to test the various possible use cases?

Change 928880 had a related patch set uploaded (by Andrew Bogott; author: Andrew Bogott):

[operations/puppet@production] keystone: allow password auth for osstackcanary user

https://gerrit.wikimedia.org/r/928880

I've merged https://gerrit.wikimedia.org/r/c/operations/puppet/+/928880 which allows password access (e.g. what cumin does) for the osstackcanary user.

You can see the roles granted to that user:

andrew@cloudcontrol1005:~$ sudo wmcs-openstack role assignment list --user osstackcanary
+----------------------------------+---------------+-------+---------------------+--------+--------+-----------+

RoleUserGroupProjectDomainSystemInherited

+----------------------------------+---------------+-------+---------------------+--------+--------+-----------+

38676f30eaeb44518bf7e144a73c8da6osstackcanaryadmin-monitoringFalse
f75a3c410bca4e96a1cf6ac103b0ccafosstackcanaryadmin-monitoringFalse
f75a3c410bca4e96a1cf6ac103b0ccafosstackcanarybastionFalse
f75a3c410bca4e96a1cf6ac103b0ccafosstackcanarypolicy-test-projectFalse
38676f30eaeb44518bf7e144a73c8da6osstackcanarytestlabsFalse
f75a3c410bca4e96a1cf6ac103b0ccafosstackcanarytestlabsFalse

+----------------------------------+---------------+-------+---------------------+--------+--------+-----------+

The credentials for that service user can be found in root@cloudcontrol1005:~/.config/openstack/clouds.yaml.

If you want more fine-grained control you can write a similar patch to the above for your personal account, then revert when you finish testing.

I think you'll find that A:all fails for osstackcanary both before and after my proposed patch. If you'd like to define what you would consider correct behavior for that use case I can work on a separate patch to implement that.

Change 928880 merged by Andrew Bogott:

[operations/puppet@production] keystone: allow password auth for osstackcanary user

https://gerrit.wikimedia.org/r/928880

Oh, btw, you'll probably need something like https://gerrit.wikimedia.org/r/c/operations/puppet/+/869319 added to your creds for this to work usefully.

Volans triaged this task as Medium priority.Jan 8 2024, 3:37 PM

Merging this with T346453 as the testing plan outlined in T346453#9713036 will cover also this use use case.