Skip to content

Commit

Permalink
Ignore deleted services in minimum version calculation
Browse files Browse the repository at this point in the history
When we go to detect the minimum version for a given service, we
should ignore any deleted services. Without this, we will return
the minimum version of all records, including those that have been
deleted with "nova service-delete". This patch filters deleted
services from the query.

Closes-Bug: #1668310
Change-Id: Ic96a5eb3728f97a3c35d2c5121e6fdcd4fd1c70b
(cherry picked from commit c79770e)
  • Loading branch information
kk7ds authored and mriedem committed Feb 27, 2017
1 parent 6087675 commit a1dd547
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions nova/db/sqlalchemy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def service_get_minimum_version(context, binaries):
models.Service.binary,
func.min(models.Service.version)).\
filter(models.Service.binary.in_(binaries)).\
filter(models.Service.deleted == 0).\
filter(models.Service.forced_down == false()).\
group_by(models.Service.binary)
return dict(min_versions)
Expand Down
4 changes: 4 additions & 0 deletions nova/tests/unit/db/test_db_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3601,6 +3601,10 @@ def test_service_get_minimum_version(self):
self._create_service({'version': 3,
'host': 'host2',
'binary': 'compute'})
self._create_service({'version': 0,
'host': 'host0',
'binary': 'compute',
'deleted': 1})
self.assertEqual({'compute': 2},
db.service_get_minimum_version(self.ctxt,
['compute']))
Expand Down

0 comments on commit a1dd547

Please sign in to comment.