Delete backup created during replication
During replication, backup of the master instance is taken, and a slave is created using this backup. This patch cleans up the backup which is created during this process (irrespective of whether it was successfully provisioned or not). Closes-Bug: #1359354 Change-Id: Ic636ffeb0bbfb9e6cc02690efe812ffc11bda85c
This commit is contained in:
parent
f53ba94468
commit
00b2b61bd5
|
@ -14,10 +14,11 @@
|
|||
# under the License.
|
||||
from trove.common.context import TroveContext
|
||||
|
||||
import trove.extensions.mgmt.instances.models as mgmtmodels
|
||||
from trove.backup.models import Backup
|
||||
import trove.common.cfg as cfg
|
||||
from trove.common import exception
|
||||
from trove.common import strategy
|
||||
import trove.extensions.mgmt.instances.models as mgmtmodels
|
||||
from trove.openstack.common import log as logging
|
||||
from trove.openstack.common import importutils
|
||||
from trove.openstack.common import periodic_task
|
||||
|
@ -93,12 +94,15 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
|
||||
snapshot = instance_tasks.get_replication_master_snapshot(context,
|
||||
slave_of_id)
|
||||
instance_tasks.create_instance(flavor, image_id, databases, users,
|
||||
datastore_manager, packages,
|
||||
volume_size,
|
||||
snapshot['dataset']['snapshot_id'],
|
||||
availability_zone, root_password,
|
||||
nics, overrides, None)
|
||||
try:
|
||||
instance_tasks.create_instance(flavor, image_id, databases, users,
|
||||
datastore_manager, packages,
|
||||
volume_size,
|
||||
snapshot['dataset']['snapshot_id'],
|
||||
availability_zone, root_password,
|
||||
nics, overrides, None)
|
||||
finally:
|
||||
Backup.delete(context, snapshot['dataset']['snapshot_id'])
|
||||
|
||||
instance_tasks.attach_replication_slave(snapshot)
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ from eventlet import greenthread
|
|||
from novaclient import exceptions as nova_exceptions
|
||||
|
||||
from trove.backup import models as bkup_models
|
||||
from trove.backup.models import Backup
|
||||
from trove.backup.models import BackupState
|
||||
from trove.backup.models import DBBackup
|
||||
from trove.cluster.models import Cluster
|
||||
|
@ -357,7 +358,11 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
|
|||
"for new replica %(replica)s.") % {'source': slave_of_id,
|
||||
'replica': self.id})
|
||||
err = inst_models.InstanceTasks.BUILDING_ERROR_SLAVE
|
||||
Backup.delete(context, snapshot_info['id'])
|
||||
self._log_and_raise(e, msg, err)
|
||||
except Exception:
|
||||
Backup.delete(context, snapshot_info['id'])
|
||||
raise
|
||||
|
||||
def report_root_enabled(self):
|
||||
mysql_models.RootHistory.create(self.context, self.id, 'root')
|
||||
|
|
|
@ -90,8 +90,6 @@ class WaitForCreateSlaveToFinish(object):
|
|||
return True
|
||||
else:
|
||||
assert_true(instance.status in ['BUILD', 'BACKUP'])
|
||||
# if instance_info.volume is not None:
|
||||
# assert_equal(instance.volume.get('used', None), None)
|
||||
return False
|
||||
poll_until(result_is_active)
|
||||
|
||||
|
@ -115,6 +113,11 @@ class VerifySlave(object):
|
|||
def test_correctly_started_replication(self):
|
||||
poll_until(slave_is_running())
|
||||
|
||||
@test(runs_after=[test_correctly_started_replication])
|
||||
def test_backup_deleted(self):
|
||||
backup = instance_info.dbaas.instances.backups(instance_info.id)
|
||||
assert_equal(len(backup), 0)
|
||||
|
||||
@test(depends_on=[test_correctly_started_replication])
|
||||
def test_create_db_on_master(self):
|
||||
databases = [{'name': slave_instance.replicated_db}]
|
||||
|
|
Loading…
Reference in New Issue