Bringing in the Endpoint Filter Group blueprint into Openstack client. Endpoint filter groups have been around in Keystone since the days of KILO but only picked up by Openstack client in v3.15. In the absence of Endpoint filter groups, clients are responsible for filtering the endpoint list, instead of Keystone sending a tailored list. For e.g. in Distributed Cloud, local Openstack services in the Central Region should not be seeing endpoints for subclouds, as they don't directly communicate with subclouds. As part of this blueprint we also had to bring in an important commit that Optimizes the command "openstack endpoint list". The current behavior is to make a Service call for each Endpoint in the Endpoint list, so for N endpoints yo have N + 1 calls to Keystone. The new behavior makes 1 call for Endpoint list, and 1 call for Service list and works with the two lists... so you do down from (N+1) calls to 2 Change-Id: I9c03938c25b56d64b59ce42cae5026f2830f02b7 Signed-off-by: Tyler Smith <tyler.smith@windriver.com>
100 lines
4.2 KiB
Diff
100 lines
4.2 KiB
Diff
From f6f5ce03c5b8a03180db24a02dda5b30f40b4cee Mon Sep 17 00:00:00 2001
|
|
From: Anton Frolov <af9740@att.com>
|
|
Date: Mon, 25 Sep 2017 12:31:24 -0700
|
|
Subject: [PATCH] Optimize getting endpoint list
|
|
|
|
Currently ListEndpoint.take_action method unconditionally iterates
|
|
over all endpoints and issue GET /v3/services/<ep.service_id>
|
|
request for each endpoint. In case of HTTPS keystone endpoint this
|
|
can take significant amout of time, and it only getting worse in
|
|
case of multiple regions.
|
|
|
|
This commit change this logic to making just two GET requests: first
|
|
it gets endpoint list, then it gets service list, searching service
|
|
in the list instead of issuing GET /v3/services/<id> request.
|
|
|
|
Change-Id: I22b61c0b45b0205a2f5a4608c2473cb7814fe3cf
|
|
Closes-Bug: 1719413
|
|
---
|
|
openstackclient/identity/common.py | 10 ++++++++++
|
|
openstackclient/identity/v3/endpoint.py | 3 ++-
|
|
openstackclient/tests/unit/identity/v3/test_endpoint.py | 2 ++
|
|
releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml | 8 ++++++++
|
|
4 files changed, 22 insertions(+), 1 deletion(-)
|
|
create mode 100644 releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml
|
|
|
|
diff --git a/openstackclient/identity/common.py b/openstackclient/identity/common.py
|
|
index 3dc5adb..e119f66 100644
|
|
--- a/openstackclient/identity/common.py
|
|
+++ b/openstackclient/identity/common.py
|
|
@@ -26,6 +26,16 @@ from osc_lib import utils
|
|
from openstackclient.i18n import _
|
|
|
|
|
|
+def find_service_in_list(service_list, service_id):
|
|
+ """Find a service by id in service list."""
|
|
+
|
|
+ for service in service_list:
|
|
+ if service.id == service_id:
|
|
+ return service
|
|
+ raise exceptions.CommandError(
|
|
+ "No service with a type, name or ID of '%s' exists." % service_id)
|
|
+
|
|
+
|
|
def find_service(identity_client, name_type_or_id):
|
|
"""Find a service by id, name or type."""
|
|
|
|
diff --git a/openstackclient/identity/v3/endpoint.py b/openstackclient/identity/v3/endpoint.py
|
|
index 15760a1..3b4dd0d 100644
|
|
--- a/openstackclient/identity/v3/endpoint.py
|
|
+++ b/openstackclient/identity/v3/endpoint.py
|
|
@@ -167,9 +167,10 @@ class ListEndpoint(command.Lister):
|
|
if parsed_args.region:
|
|
kwargs['region'] = parsed_args.region
|
|
data = identity_client.endpoints.list(**kwargs)
|
|
+ service_list = identity_client.services.list()
|
|
|
|
for ep in data:
|
|
- service = common.find_service(identity_client, ep.service_id)
|
|
+ service = common.find_service_in_list(service_list, ep.service_id)
|
|
ep.service_name = get_service_name(service)
|
|
ep.service_type = service.type
|
|
return (columns,
|
|
diff --git a/openstackclient/tests/unit/identity/v3/test_endpoint.py b/openstackclient/tests/unit/identity/v3/test_endpoint.py
|
|
index 765fbed..fad53fc 100644
|
|
--- a/openstackclient/tests/unit/identity/v3/test_endpoint.py
|
|
+++ b/openstackclient/tests/unit/identity/v3/test_endpoint.py
|
|
@@ -295,6 +295,7 @@ class TestEndpointList(TestEndpoint):
|
|
|
|
# This is the return value for common.find_resource(service)
|
|
self.services_mock.get.return_value = self.service
|
|
+ self.services_mock.list.return_value = [self.service]
|
|
|
|
# Get the command object to test
|
|
self.cmd = endpoint.ListEndpoint(self.app, None)
|
|
@@ -726,6 +727,7 @@ class TestEndpointListServiceWithoutName(TestEndpointList):
|
|
|
|
# This is the return value for common.find_resource(service)
|
|
self.services_mock.get.return_value = self.service
|
|
+ self.services_mock.list.return_value = [self.service]
|
|
|
|
# Get the command object to test
|
|
self.cmd = endpoint.ListEndpoint(self.app, None)
|
|
diff --git a/releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml b/releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml
|
|
new file mode 100644
|
|
index 0000000..784d19e
|
|
--- /dev/null
|
|
+++ b/releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml
|
|
@@ -0,0 +1,8 @@
|
|
+---
|
|
+fixes:
|
|
+ - |
|
|
+ Fix an issue with ``endpoint list`` working slow because it is issuing one GET
|
|
+ request to /v3/services/<id> Keystone API for each endpoint. In case of HTTPS
|
|
+ keystone endpoint and multiple regions it can take significant amount of time.
|
|
+ [Bug `1719413 <https://bugs.launchpad.net/python-openstackclient/+bug/1719413>`_]
|
|
+
|
|
--
|
|
1.8.3.1
|
|
|