Skip to content

Commit 85f6166

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix image/tasks API for in-progress tasks" into stable/wallaby
2 parents cbd0262 + 78e8b75 commit 85f6166

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

glance/db/sqlalchemy/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,8 @@ def tasks_get_by_image(context, image_id, session=None):
16721672
).filter_by(image_id=image_id)
16731673

16741674
expires_at = models.Task.expires_at
1675-
query = query.filter(expires_at >= timeutils.utcnow())
1675+
query = query.filter(sa_sql.or_(expires_at == None,
1676+
expires_at >= timeutils.utcnow()))
16761677
updated_at = models.Task.updated_at
16771678
query.filter(
16781679
updated_at <= (timeutils.utcnow() +

glance/tests/functional/db/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,13 +1774,13 @@ def test_task_get_by_image_expired(self):
17741774
self.assertTrue(tasks[0]['deleted'])
17751775

17761776
def test_task_get_by_image_no_expiry(self):
1777-
# Make sure we do not retrieve the expired task
1777+
# Make sure we find the task that has expires_at=NULL
17781778
task_id, tasks = self._test_task_get_by_image(expired=None)
1779-
self.assertEqual(0, len(tasks))
1779+
self.assertEqual(1, len(tasks))
17801780

1781-
# The task should not have been retrieved at all above,
1782-
# but it's also not deleted because it doesn't have an expiry,
1783-
# so it should still be in the DB.
1781+
# The task should have been retrieved above, and it's also not
1782+
# deleted because it doesn't have an expiry, so it should
1783+
# still be in the DB.
17841784
tasks = self.db_api.task_get_all(self.adm_context)
17851785
self.assertEqual(1, len(tasks))
17861786
self.assertEqual(task_id, tasks[0]['id'])

0 commit comments

Comments
 (0)