Trove - service_statuses status set to delete when instance deleted

A Trove Instance that is created and booted successfully has a
service_statuses status as running.When the instance is deleted
however, the service_statuses record remains unchanged.
This fix updates the status to deleted.

Change-Id: Ied0b740e2de563f6337dbbcc3c026aad2777cc53
Fixes: bug #1200373
This commit is contained in:
Riddhi Shah 2013-08-16 12:17:28 -05:00 committed by Ed Cranford
parent aa5c3ddf1b
commit fc3d2f5ed7
2 changed files with 17 additions and 0 deletions

View File

@ -360,6 +360,7 @@ class BaseInstance(SimpleInstance):
LOG.warn(ex)
self.update_db(deleted=True, deleted_at=deleted_at,
task_status=InstanceTasks.NONE)
self.set_servicestatus_deleted()
# Delete associated security group
if CONF.trove_security_groups_support:
SecurityGroup.delete_for_instance(self.db_info.id,
@ -383,6 +384,11 @@ class BaseInstance(SimpleInstance):
setattr(self.db_info, key, values[key])
self.db_info.save()
def set_servicestatus_deleted(self):
del_instance = InstanceServiceStatus.find_by(instance_id=self.id)
del_instance.set_status(ServiceStatuses.DELETED)
del_instance.save()
@property
def volume_client(self):
if not self._volume_client:
@ -820,6 +826,7 @@ class ServiceStatuses(object):
BUILDING = ServiceStatus(0x09, 'building', 'BUILD')
UNKNOWN = ServiceStatus(0x16, 'unknown', 'ERROR')
NEW = ServiceStatus(0x17, 'new', 'NEW')
DELETED = ServiceStatus(0x05, 'deleted', 'DELETED')
MYSQL_RESPONSIVE_STATUSES = [ServiceStatuses.RUNNING]

View File

@ -1060,6 +1060,16 @@ class AfterDeleteChecks(object):
'trove.instance.delete',
**expected)
@test
def test_instance_status_deleted_in_db(self):
mgmt_details = dbaas_admin.management.index(deleted=True)
for instance in mgmt_details:
if instance.id == instance_info.id:
assert_equal(instance.service_status, 'DELETED')
break
else:
fail("Could not find instance %s" % instance_info.id)
@test(depends_on_classes=[CreateInstance, VerifyGuestStarted,
WaitForGuestInstallationToFinish],