Skip to content

Commit a958dcb

Browse files
Merge pull request #1038 from zhaoqin-github/cherry-pick-4e7eb06
avoid getting lb from db
2 parents dbc28b1 + 466f0da commit a958dcb

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

f5lbaasdriver/v2/bigip/agent_scheduler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,12 @@ def schedule(self, plugin, context, loadbalancer_id, env=None):
200200
"""
201201

202202
with context.session.begin(subtransactions=True):
203-
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
204203
# If the loadbalancer is hosted on an active agent
205204
# already, return that agent or one in its env
206205
lbaas_agent = self.get_lbaas_agent_hosting_loadbalancer(
207206
plugin,
208207
context,
209-
loadbalancer.id,
208+
loadbalancer_id,
210209
env
211210
)
212211

@@ -216,6 +215,14 @@ def schedule(self, plugin, context, loadbalancer_id, env=None):
216215
% (lbaas_agent['id']))
217216
return lbaas_agent
218217

218+
# moving this part here so that this db call basically only called
219+
# while creating lb. If it was for creating lb, then this call
220+
# returns immediately. For other ops, it should have returned
221+
# already above, so this db call is avoided.
222+
LOG.info('get_loadbalancer start inside schedule')
223+
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
224+
LOG.info('get_loadbalancer end inside schedule')
225+
219226
# There is no existing loadbalancer agent binding.
220227
# Find all active agent candidates in this env.
221228
# We use environment_prefix to find F5® agents

0 commit comments

Comments
 (0)