-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[STACK-2950]: Batch member update optimization for Rack flows #559
base: feature/batch_member_update_enhancement
Are you sure you want to change the base?
[STACK-2950]: Batch member update optimization for Rack flows #559
Conversation
…ntryForBatchMembers
…odified ValidateSubnet task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides running the batch flow parallel.
- please help test the delete 2 (all) memeber in same ip address case.
- The key for the enhancement is to reduce the database query. Since I/O take more time. So, If we just move the db query from loop to another loop. It may not help.
- But with our investigation, the most time was spend on running axapi one by one. Even we reduce the db query times, may not help the performance.
member.ip_address in mem_count_ip_port_protocol_dict): | ||
mem_cnt_ip_port_proto = mem_count_ip_port_protocol_dict[member.ip_address] | ||
member_count_ip_port_protocol = mem_cnt_ip_port_proto | ||
|
||
if member_count_ip <= 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can test this scenario?
create 2 members:
member {
address = "10.0.12.54"
subnet_id = "da29e3b4-c885-4834-b4ee-228d7d1bfac1"
protocol_port = 95
name = "m6"
weight = 10
}
member {
address = "10.0.12.54"
subnet_id = "da29e3b4-c885-4834-b4ee-228d7d1bfac1"
protocol_port = 96
name = "m7"
weight = 15
}
and then delete both of them by batch member update. Will the slb server be delete on thunder? since the member_count_ip should be 2 in this case.
mem_count_ip_dict = {} | ||
mem_count_ip_port_protocol_dict = {} | ||
for member in members: | ||
cnt_ip = self.member_repo.get_member_count_by_ip_address( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can skip the database query if mem_count_ip_dict[member.ip_address] already exist
if nat_flavor and 'pool_name' in nat_flavor: | ||
try: | ||
for member in members: | ||
nat_pool = self.nat_pool_repo.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip the db query if nat_pool_dict[member.subnet_id] already exist
inject={a10constants.MEMBERS: members}, | ||
requires=[a10constants.NAT_FLAVOR], | ||
provides=a10constants.NAT_POOL_DICT)) | ||
if new_members: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the address release/reservation after member are created/deleted?
In case error happened, we don't need to implement reverse function for them.
member.ip_address, member_subnet.cidr) | ||
|
||
|
||
class DeleteSubnetAddressAndNatPoolForBatchMembers(BaseNetworkTask): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better we can aggregate the reference count. And then update db, reserver/release addresses.
The total db query and address reserver/release operation is the same as before.
Description
Created batch tasks and added them into batch_member_update rack flows to gather batch of member related information beforehand instead of calling some tasks repeatedly for each member in a batch query using for loops.
Jira Ticket
https://a10networks.atlassian.net/browse/STACK-3178
https://a10networks.atlassian.net/browse/STACK-3179
https://a10networks.atlassian.net/browse/STACK-3180
https://a10networks.atlassian.net/browse/STACK-3181
https://a10networks.atlassian.net/browse/STACK-3184
https://a10networks.atlassian.net/browse/STACK-3185
Technical Approach
CountBatchMembersWithIPPortProtocol()
for getting 2 dictionaries{member_ip_address: member_count_ip}
and{member_ip_address: member_count_ip_port_protocol}
which contains new members and old members for a batch update in it.GetNatPoolEntryForBatchMembers()
for getting a dictionary{member_subnet_id: nat_pool}
specific to old members in a batch update.DeleteSubnetAddressAndNatPoolForBatchMembers()
for releasing subnet_address and nat_pool associated to all the member in a list of old_members in a batch update.ValidateSubnet()
task sothat it can work on a list of members as well in case of batch update.MemberCreate()
andMemberDelete()
tasks such thatmember_count_ip
andmember_count_ip_port_protocol
required in it can be fetched from the dictionaries got from theCountBatchMembersWithIPPortProtocol()
batch tasks by looking into the dictionaries and getting the counts respective to the member which is to be deleted/created.get_rack_vthunder_batch_update_members_flow
before starting for loops for new_members, old_members and updated_members.Config Changes
N/A
Manual Testing
stack@openstack-3:~$ openstack loadbalancer flavorprofile show fpn
stack@openstack-3:~$ openstack loadbalancer flavor show fn
stack@openstack-3:~$ openstack loadbalancer create --name lb1 --vip-subnet-id public-11-subnet --flavor fn
stack@openstack-3:~$ openstack loadbalancer listener create --name l1 --protocol http --protocol-port 80 lb1
stack@openstack-3:~$ openstack loadbalancer pool create --name p1 --protocol HTTP --lb-algorithm LEAST_CONNECTIONS --listener l1
Result on vThunder:
stack@openstack-3:~/neha$ time terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
openstack_lb_members_v2.members_1 will be created
id = (known after apply)
pool_id = "70cfaa46-c7a6-441f-82c7-17e1052fc0d4"
region = (known after apply)
member {
}
member {
}
member {
}
member {
}
member {
}
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
openstack_lb_members_v2.members_1: Creating...
openstack_lb_members_v2.members_1: Still creating... [10s elapsed]
openstack_lb_members_v2.members_1: Creation complete after 11s [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
real 0m17.510s
user 0m1.928s
sys 0m0.382s
stack@openstack-3:~/neha$ openstack loadbalancer member list p1
Result on vThunder:
vThunder(NOLICENSE)#show running-config
!Current configuration: 196 bytes
!Configuration last updated at 07:02:28 GMT Wed Dec 1 2021
!Configuration last saved at 07:02:31 GMT Wed Dec 1 2021
!64-bit Advanced Core OS (ACOS) version 5.2.1, build 153 (Dec-11-2020,14:16)
!
!
interface management
ip address dhcp
!
interface ethernet 1
!
interface ethernet 2
!
vrrp-a vrid 0
floating-ip 10.0.11.164
floating-ip 10.0.12.176
!
ip nat pool pool1 10.0.12.11 10.0.12.12 netmask /24
!
slb server 9ef5e_10_0_12_44 10.0.12.44
port 90 tcp
!
slb server 9ef5e_10_0_12_45 10.0.12.45
port 91 tcp
!
slb server 9ef5e_10_0_12_46 10.0.12.46
port 92 tcp
port 94 tcp
!
slb server 9ef5e_10_0_12_47 10.0.12.47
port 93 tcp
!
slb service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4 tcp
method least-connection
member 9ef5e_10_0_12_44 90
member 9ef5e_10_0_12_45 91
member 9ef5e_10_0_12_46 92
member 9ef5e_10_0_12_46 94
member 9ef5e_10_0_12_47 93
!
slb virtual-server 7ae7360f-3cdc-4bb3-83d4-362f22ed3499 10.0.11.182
port 80 http
name 7f81dbf3-f9dd-4ac2-a500-5d5f49f9485a
extended-stats
source-nat pool pool1
service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4
!
!
cloud-services meta-data
enable
provider openstack
!
end
!Current config commit point for partition 0 is 0 & config mode is classical-mode
stack@openstack-3:~/neha$ time terraform apply
openstack_lb_members_v2.members_1: Refreshing state... [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
openstack_lb_members_v2.members_1 will be updated in-place
~ resource "openstack_lb_members_v2" "members_1" {
id = "70cfaa46-c7a6-441f-82c7-17e1052fc0d4"
# (1 unchanged attribute hidden)
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
openstack_lb_members_v2.members_1: Modifying... [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
openstack_lb_members_v2.members_1: Still modifying... [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4, 10s elapsed]
openstack_lb_members_v2.members_1: Modifications complete after 12s [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
real 0m15.133s
user 0m2.169s
sys 0m0.329s
stack@openstack-3:~/neha$ openstack loadbalancer member list p1
Result on vThunder:
vThunder(NOLICENSE)#show running-config
!Current configuration: 196 bytes
!Configuration last updated at 07:08:10 GMT Wed Dec 1 2021
!Configuration last saved at 07:08:12 GMT Wed Dec 1 2021
!64-bit Advanced Core OS (ACOS) version 5.2.1, build 153 (Dec-11-2020,14:16)
!
!
interface management
ip address dhcp
!
interface ethernet 1
!
interface ethernet 2
!
vrrp-a vrid 0
floating-ip 10.0.11.164
floating-ip 10.0.12.130
!
ip nat pool pool1 10.0.12.11 10.0.12.12 netmask /24
!
slb server 9ef5e_10_0_12_47 10.0.12.47
disable
port 93 tcp
!
slb server 9ef5e_10_0_12_46 10.0.12.46
disable
port 94 tcp
!
slb server 9ef5e_10_0_12_54 10.0.12.54
port 95 tcp
!
slb server 9ef5e_10_0_12_55 10.0.12.55
port 96 tcp
!
slb server 9ef5e_10_0_12_56 10.0.12.56
port 97 tcp
!
slb service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4 tcp
method least-connection
member 9ef5e_10_0_12_47 93
member 9ef5e_10_0_12_54 95
member 9ef5e_10_0_12_55 96
member 9ef5e_10_0_12_56 97
!
slb virtual-server 7ae7360f-3cdc-4bb3-83d4-362f22ed3499 10.0.11.182
port 80 http
name 7f81dbf3-f9dd-4ac2-a500-5d5f49f9485a
extended-stats
source-nat pool pool1
service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4
!
!
cloud-services meta-data
enable
provider openstack
!
end
!Current config commit point for partition 0 is 0 & config mode is classical-mode
stack@openstack-3:~/neha$ time terraform apply
openstack_lb_members_v2.members_1: Refreshing state... [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
openstack_lb_members_v2.members_1 will be updated in-place
~ resource "openstack_lb_members_v2" "members_1" {
id = "70cfaa46-c7a6-441f-82c7-17e1052fc0d4"
# (1 unchanged attribute hidden)
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
openstack_lb_members_v2.members_1: Modifying... [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
openstack_lb_members_v2.members_1: Still modifying... [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4, 10s elapsed]
openstack_lb_members_v2.members_1: Modifications complete after 11s [id=70cfaa46-c7a6-441f-82c7-17e1052fc0d4]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
real 0m13.891s
user 0m1.908s
sys 0m0.623s
stack@openstack-3:~/neha$ openstack loadbalancer member list p1
Result on vThunder:
vThunder(NOLICENSE)#show running-config
!Current configuration: 196 bytes
!Configuration last updated at 07:13:49 GMT Wed Dec 1 2021
!Configuration last saved at 07:13:52 GMT Wed Dec 1 2021
!64-bit Advanced Core OS (ACOS) version 5.2.1, build 153 (Dec-11-2020,14:16)
!
!
interface management
ip address dhcp
!
interface ethernet 1
!
interface ethernet 2
!
vrrp-a vrid 0
floating-ip 10.0.11.164
floating-ip 10.0.12.54
!
ip nat pool pool1 10.0.12.11 10.0.12.12 netmask /24
!
slb server 9ef5e_10_0_12_54 10.0.12.54
port 95 tcp
!
slb service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4 tcp
method least-connection
member 9ef5e_10_0_12_54 95
!
slb virtual-server 7ae7360f-3cdc-4bb3-83d4-362f22ed3499 10.0.11.182
port 80 http
name 7f81dbf3-f9dd-4ac2-a500-5d5f49f9485a
extended-stats
source-nat pool pool1
service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4
!
!
cloud-services meta-data
enable
provider openstack
!
end
stack@openstack-3:
/neha$ openstack loadbalancer member delete p1 m6/neha$ openstack loadbalancer member list p1stack@openstack-3:
Result on vThunder:
vThunder(NOLICENSE)#show running-config
!Current configuration: 283 bytes
!Configuration last updated at 07:19:09 GMT Wed Dec 1 2021
!Configuration last saved at 07:19:13 GMT Wed Dec 1 2021
!64-bit Advanced Core OS (ACOS) version 5.2.1, build 153 (Dec-11-2020,14:16)
!
!
interface management
ip address dhcp
!
interface ethernet 1
!
interface ethernet 2
!
vrrp-a vrid 0
floating-ip 10.0.11.164
!
ip nat pool pool1 10.0.12.11 10.0.12.12 netmask /24
!
slb service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4 tcp
method least-connection
!
slb virtual-server 7ae7360f-3cdc-4bb3-83d4-362f22ed3499 10.0.11.182
port 80 http
name 7f81dbf3-f9dd-4ac2-a500-5d5f49f9485a
extended-stats
source-nat pool pool1
service-group 70cfaa46-c7a6-441f-82c7-17e1052fc0d4
!
!
cloud-services meta-data
enable
provider openstack
!
end