Skip to content

Commit

Permalink
Correct deleted_at value in notification messages
Browse files Browse the repository at this point in the history
The deleted_at value in notification messages is currently
set from the terminated_at value in the instance record.

A comment in the code says this is to avoid confusion between
terminated_at and deleted_at,  but swapping the names doesn't
seem to be a great way to address that.

In practice "terminated and not deleted" is a transient state
unless an error occurs, and the time gap is very short.  But
deleted_at is always set when the entry is deleted in the DB,
whereas terminated_at can be left unset in some error cases.

Rather than present terminated_at as the deleted_at value in
the message we include both and let the recipient decide which
they want to use.

Fixes bug: 1227080

Change-Id: Ic67f66b6c64be1a8f43f4fdd5b1fac25f1414247
  • Loading branch information
Phil Day committed Sep 20, 2013
1 parent b4661db commit 268a7d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions nova/notifications.py
Expand Up @@ -381,10 +381,11 @@ def null_safe_isotime(s):

# Date properties
created_at=str(instance_ref['created_at']),
# Nova's deleted vs terminated instance terminology is confusing,
# this should be when the instance was deleted (i.e. terminated_at),
# not when the db record was deleted. (mdragon)
deleted_at=null_safe_isotime(instance_ref.get('terminated_at')),
# Terminated and Deleted are slightly different (although being
# terminated and not deleted is a transient state), so include
# both and let the recipient decide which they want to use.
terminated_at=null_safe_isotime(instance_ref.get('terminated_at')),
deleted_at=null_safe_isotime(instance_ref.get('deleted_at')),
launched_at=null_safe_isotime(instance_ref.get('launched_at')),

# Image properties
Expand Down
3 changes: 2 additions & 1 deletion nova/tests/compute/test_compute.py
Expand Up @@ -2872,8 +2872,9 @@ def test_terminate_usage_notification(self):
self.assertTrue('display_name' in payload)
self.assertTrue('created_at' in payload)
self.assertTrue('launched_at' in payload)
self.assertTrue('terminated_at' in payload)
self.assertTrue('deleted_at' in payload)
self.assertEqual(payload['deleted_at'], timeutils.strtime(cur_time))
self.assertEqual(payload['terminated_at'], timeutils.strtime(cur_time))
image_ref_url = glance.generate_image_url(FAKE_IMAGE_REF)
self.assertEquals(payload['image_ref_url'], image_ref_url)

Expand Down

0 comments on commit 268a7d4

Please sign in to comment.