Skip to content

Commit

Permalink
Merge pull request #1035 from Niklaus-xie/h3c-pike-not-get-lb-when-sc…
Browse files Browse the repository at this point in the history
…hed-better-way

avoid getting lb from db without modifying prototype of schedule
  • Loading branch information
Niklaus-xie authored Nov 13, 2020
2 parents 778e879 + 4e7eb06 commit a04e5b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions f5lbaasdriver/v2/bigip/agent_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,12 @@ def schedule(self, plugin, context, loadbalancer_id, env=None):
"""

with context.session.begin(subtransactions=True):
LOG.info('get_loadbalancer start')
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
LOG.info('get_loadbalancer end')
# If the loadbalancer is hosted on an active agent
# already, return that agent or one in its env
lbaas_agent = self.get_lbaas_agent_hosting_loadbalancer(
plugin,
context,
loadbalancer.id,
loadbalancer_id,
env
)

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

# moving this part here so that this db call basically only called
# while creating lb. If it was for creating lb, then this call
# returns immediately. For other ops, it should have returned
# already above, so this db call is avoided.
LOG.info('get_loadbalancer start inside schedule')
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
LOG.info('get_loadbalancer end inside schedule')

# There is no existing loadbalancer agent binding.
# Find all active agent candidates in this env.
# We use environment_prefix to find F5® agents
Expand Down

0 comments on commit a04e5b7

Please sign in to comment.