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.

Conflicts:
        nova/db/sqlalchemy/api.py
        nova/tests/unit/db/test_db_api.py

NOTE(mriedem): The conflicts are due to not having change
11cb56a in Mitaka.

Closes-Bug: #1668310
Change-Id: Ic96a5eb3728f97a3c35d2c5121e6fdcd4fd1c70b
(cherry picked from commit c79770e)
(cherry picked from commit a1dd547)
(cherry picked from commit 1ad5c73)
  • Loading branch information
kk7ds authored and mriedem committed Feb 27, 2017
1 parent fb1b9f2 commit 2e05c82
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
Expand Up @@ -512,6 +512,7 @@ def service_get_minimum_version(context, binary):
min_version = context.session.query(
func.min(models.Service.version)).\
filter(models.Service.binary == binary).\
filter(models.Service.deleted == 0).\
filter(models.Service.forced_down == false()).\
scalar()
return min_version
Expand Down
4 changes: 4 additions & 0 deletions nova/tests/unit/db/test_db_api.py
Expand Up @@ -3427,6 +3427,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(2, db.service_get_minimum_version(self.ctxt,
'compute'))

Expand Down

0 comments on commit 2e05c82

Please sign in to comment.