summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorMichael Kerrin <michael.kerrin@hp.com>2013-06-06 08:52:52 +0000
committerMichael Kerrin <michael.kerrin@hp.com>2013-06-07 16:03:09 +0000
commit4aee80dd31131675ae0ab9f927b2d4aed0b8426a (patch)
tree4baaf55a8b2ef11a24e884018f644d689c06fd8c /nova/db
parent7a475d3cd606e68090075c1a8944e3aeb7898b87 (diff)
downloadnova-4aee80dd31131675ae0ab9f927b2d4aed0b8426a.tar.gz
nova-4aee80dd31131675ae0ab9f927b2d4aed0b8426a.tar.xz
nova-4aee80dd31131675ae0ab9f927b2d4aed0b8426a.zip
Sending volume IO usage broken
This is my fault, I didn't test the sending of notifications enough when fixing bug 1182102, when the volume IO usage notifications were been sent too often. This was merged as part of https://review.openstack.org/#/c/29915 The issue was that the code worked for the first IO usage event (the one I looked at). Then when constructing the event payload for the second and following IO usage events the code path ended up comparing a datetime object from the db with a cached string representation of the last_refreshed date that was passed into the conductor via the RPC. Since last_refreshed argument to vol_usage_update in the db layer is not needed and is causing these issues. I have removed last_refreshed argument from the db layer and deprecated it from the conduction API. Change-Id: I2030eb7912c56134ea688a6e8bbfcdeddca28307
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py4
-rw-r--r--nova/db/sqlalchemy/api.py14
2 files changed, 7 insertions, 11 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 78e2eb7a4..37c486ca7 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -1469,14 +1469,12 @@ def vol_get_usage_by_time(context, begin):
def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
instance_id, project_id, user_id, availability_zone,
- last_refreshed=None, update_totals=False,
- session=None):
+ update_totals=False, session=None):
"""Update cached volume usage for a volume
Creates new record if needed."""
return IMPL.vol_usage_update(context, id, rd_req, rd_bytes, wr_req,
wr_bytes, instance_id, project_id, user_id,
availability_zone,
- last_refreshed=last_refreshed,
update_totals=update_totals,
session=session)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index af9486b3e..ef58bdd6c 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -4392,19 +4392,18 @@ def vol_get_usage_by_time(context, begin):
@require_context
def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
instance_id, project_id, user_id, availability_zone,
- last_refreshed=None, update_totals=False, session=None):
+ update_totals=False, session=None):
if not session:
session = get_session()
- if last_refreshed is None:
- last_refreshed = timeutils.utcnow()
+ refreshed = timeutils.utcnow()
with session.begin():
values = {}
# NOTE(dricco): We will be mostly updating current usage records vs
# updating total or creating records. Optimize accordingly.
if not update_totals:
- values = {'curr_last_refreshed': last_refreshed,
+ values = {'curr_last_refreshed': refreshed,
'curr_reads': rd_req,
'curr_read_bytes': rd_bytes,
'curr_writes': wr_req,
@@ -4414,7 +4413,7 @@ def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
'user_id': user_id,
'availability_zone': availability_zone}
else:
- values = {'tot_last_refreshed': last_refreshed,
+ values = {'tot_last_refreshed': refreshed,
'tot_reads': models.VolumeUsage.tot_reads + rd_req,
'tot_read_bytes': models.VolumeUsage.tot_read_bytes +
rd_bytes,
@@ -4443,7 +4442,6 @@ def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
"the database. Instance must have been rebooted "
"or crashed. Updating totals.") % id)
if not update_totals:
- values['tot_last_refreshed'] = last_refreshed
values['tot_reads'] = (models.VolumeUsage.tot_reads +
current_usage['curr_reads'])
values['tot_read_bytes'] = (
@@ -4472,8 +4470,6 @@ def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
return current_usage
vol_usage = models.VolumeUsage()
- vol_usage.tot_last_refreshed = timeutils.utcnow()
- vol_usage.curr_last_refreshed = timeutils.utcnow()
vol_usage.volume_id = id
vol_usage.instance_uuid = instance_id
vol_usage.project_id = project_id
@@ -4481,11 +4477,13 @@ def vol_usage_update(context, id, rd_req, rd_bytes, wr_req, wr_bytes,
vol_usage.availability_zone = availability_zone
if not update_totals:
+ vol_usage.curr_last_refreshed = refreshed
vol_usage.curr_reads = rd_req
vol_usage.curr_read_bytes = rd_bytes
vol_usage.curr_writes = wr_req
vol_usage.curr_write_bytes = wr_bytes
else:
+ vol_usage.tot_last_refreshed = refreshed
vol_usage.tot_reads = rd_req
vol_usage.tot_read_bytes = rd_bytes
vol_usage.tot_writes = wr_req