Skip to content

Commit a04e5b7

Browse files
authored
Merge pull request #1035 from Niklaus-xie/h3c-pike-not-get-lb-when-sched-better-way
avoid getting lb from db without modifying prototype of schedule
2 parents 778e879 + 4e7eb06 commit a04e5b7

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

f5lbaasdriver/v2/bigip/agent_scheduler.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,12 @@ def schedule(self, plugin, context, loadbalancer_id, env=None):
189189
"""
190190

191191
with context.session.begin(subtransactions=True):
192-
LOG.info('get_loadbalancer start')
193-
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
194-
LOG.info('get_loadbalancer end')
195192
# If the loadbalancer is hosted on an active agent
196193
# already, return that agent or one in its env
197194
lbaas_agent = self.get_lbaas_agent_hosting_loadbalancer(
198195
plugin,
199196
context,
200-
loadbalancer.id,
197+
loadbalancer_id,
201198
env
202199
)
203200

@@ -207,6 +204,14 @@ def schedule(self, plugin, context, loadbalancer_id, env=None):
207204
% (lbaas_agent['id']))
208205
return lbaas_agent
209206

207+
# moving this part here so that this db call basically only called
208+
# while creating lb. If it was for creating lb, then this call
209+
# returns immediately. For other ops, it should have returned
210+
# already above, so this db call is avoided.
211+
LOG.info('get_loadbalancer start inside schedule')
212+
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
213+
LOG.info('get_loadbalancer end inside schedule')
214+
210215
# There is no existing loadbalancer agent binding.
211216
# Find all active agent candidates in this env.
212217
# We use environment_prefix to find F5® agents

0 commit comments

Comments
 (0)