From 9f75e546aaf2b791868a3eac424462f78dca707f Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Tue, 16 Jul 2013 21:47:19 +0800 Subject: [PATCH] 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 --- cinder/db/sqlalchemy/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- 2.45.2