Fix query in get_l3_agent_with_min_routers

For PostgreSQL if you're using GROUP BY everything in the SELECT
list must be an aggregate count(...) or used in the GROUP BY.

Closes-bug: #1495523

Change-Id: Ieb75d0666ec2f6d2e61686bf2bacea2b9ad6c521
This commit is contained in:
Ann Kamyshnikova 2015-09-14 17:29:22 +03:00
parent cd4d889374
commit 5eaff5fa07
1 changed files with 1 additions and 0 deletions

View File

@ -501,6 +501,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
func.count(
RouterL3AgentBinding.router_id
).label('count')).outerjoin(RouterL3AgentBinding).group_by(
agents_db.Agent.id,
RouterL3AgentBinding.l3_agent_id).order_by('count')
res = query.filter(agents_db.Agent.id.in_(agent_ids)).first()
return res[0]