From: Haomai Wang Date: Tue, 16 Jul 2013 13:47:19 +0000 (+0800) Subject: Fix error when QuotaUsage.updated_at is NULL X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9f75e546aaf2b791868a3eac424462f78dca707f;p=openstack-build%2Fcinder-build.git Fix error when QuotaUsage.updated_at is NULL When QuotaUsage.updated_at is None, it will raise non-expected exception. Just verify it. Fix bug 1197259 Change-Id: I2b41d025f8cffa6c0b3f0153a5194d5e7b1a05df --- diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 7259db9a2..f76d52b92 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -755,8 +755,9 @@ def quota_reserve(context, resources, quotas, deltas, expire, usages[resource].until_refresh -= 1 if usages[resource].until_refresh <= 0: refresh = True - elif max_age and (usages[resource].updated_at - - timeutils.utcnow()).seconds >= max_age: + elif max_age and usages[resource].updated_at is not None and ( + (usages[resource].updated_at - + timeutils.utcnow()).seconds >= max_age): refresh = True # OK, refresh the usage