From 22f0e324f3d3172b563aa67e513fe4d9318de2e5 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Sat, 1 Sep 2012 09:37:15 +0100 Subject: Fix quota reservation expiration Fixes bug #1040942 The db.reservation_expire() function assumes a 'usage' attribute on Reservation objects, but we don't actually define that relationship. The end result is that reservation_expire() currently traceback if it actually needs to expire any reservations. This happens pretty rarely since reservations should only need expiring if they are leaked because of another bug. Also define a test case to actually excercise the expiration code path. Add a missing chain-up to tearDown in test_limits which was causing the get_project_quotas() stub not to be unset and, in turn, the reservation expiration test to fail. Change-Id: Ib61dbf9fd5dfb5badaf05f20c423a69925d83754 --- nova/db/sqlalchemy/models.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py index 65d5eb5e0..8b8322276 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -496,6 +496,12 @@ class Reservation(BASE, NovaBase): delta = Column(Integer) expire = Column(DateTime, nullable=False) + usage = relationship( + "QuotaUsage", + foreign_keys=usage_id, + primaryjoin='and_(Reservation.usage_id == QuotaUsage.id,' + 'QuotaUsage.deleted == False)') + class Snapshot(BASE, NovaBase): """Represents a block storage device that can be attached to a VM.""" -- cgit