]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix error when QuotaUsage.updated_at is NULL
authorHaomai Wang <haomai@unitedstack.com>
Tue, 16 Jul 2013 13:47:19 +0000 (21:47 +0800)
committerHaomai Wang <haomai@unitedstack.com>
Wed, 17 Jul 2013 02:34:36 +0000 (10:34 +0800)
When QuotaUsage.updated_at is None, it will raise non-expected exception.
Just verify it.

Fix bug 1197259

Change-Id: I2b41d025f8cffa6c0b3f0153a5194d5e7b1a05df

cinder/db/sqlalchemy/api.py

index 7259db9a20dd653be88118bd6405b98844f29f29..f76d52b9242ffff5c8ad97a578e7e222f0cd60bc 100644 (file)
@@ -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