Skip to content

Commit 4f49545

Browse files
committed
[neutron] Get only ID and name of the SGs from Neutron
During the VM booting process Nova asks Neutron for the security groups of the project. If there are no any fields specified, Neutron will prepare list of security groups with all fields, including rules. In case if project got many SGs, it may take long time as rules needs to be loaded separately for each SG on Neutron's side. During booting of the VM, Nova really needs only "id" and "name" of the security groups so this patch limits request to only those 2 fields. This lazy loading of the SG rules was introduced in Neutron in [1] and [2]. [1] https://review.opendev.org/#/c/630401/ [2] https://review.opendev.org/#/c/637407/ Related-Bug: #1865223 Change-Id: I15c3119857970c38541f4de270bd561166334548 (cherry picked from commit 388498a)
1 parent 68af588 commit 4f49545

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nova/network/neutron.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,15 @@ def _process_security_groups(self, instance, neutron, security_groups):
802802
# TODO(arosen) Should optimize more to do direct query for security
803803
# group if len(security_groups) == 1
804804
if len(security_groups):
805+
# NOTE(slaweq): fields other than name and id aren't really needed
806+
# so asking only about those fields will allow Neutron to not
807+
# prepare list of rules for each found security group. That may
808+
# speed processing of this request a lot in case when tenant has
809+
# got many security groups
810+
sg_fields = ['id', 'name']
805811
search_opts = {'tenant_id': instance.project_id}
806812
user_security_groups = neutron.list_security_groups(
807-
**search_opts).get('security_groups')
813+
fields=sg_fields, **search_opts).get('security_groups')
808814

809815
for security_group in security_groups:
810816
name_match = None

0 commit comments

Comments
 (0)