Remove soft-delete for instances
There was widespread agreement to not soft-delete any more, so we should not keep this. Change-Id: Ia7d4daa46aa669a9b7ddf14c2f6df500b5a317ba
This commit is contained in:
parent
ce8b17d415
commit
7473e2760c
@ -71,7 +71,6 @@ def upgrade():
|
||||
'instances',
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('deleted_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('uuid', sa.String(length=36), nullable=True),
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.String(length=36), nullable=True),
|
||||
@ -86,7 +85,6 @@ def upgrade():
|
||||
sa.Column('availability_zone', sa.String(length=255), nullable=True),
|
||||
sa.Column('node_uuid', sa.String(length=36), nullable=True),
|
||||
sa.Column('extra', sa.Text(), nullable=True),
|
||||
sa.Column('deleted', sa.Integer(), nullable=False),
|
||||
sa.Column('locked', sa.Boolean(), nullable=True),
|
||||
sa.Column('locked_by', sa.Enum('admin', 'owner'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
|
@ -70,11 +70,6 @@ def model_query(context, model, *args, **kwargs):
|
||||
if kwargs.pop("project_only", False):
|
||||
kwargs["project_id"] = context.tenant
|
||||
|
||||
if kwargs.pop("instance", False):
|
||||
kwargs["deleted"] = False
|
||||
if kwargs.pop("read_deleted", False):
|
||||
kwargs["deleted"] = True
|
||||
|
||||
with _session_for_read() as session:
|
||||
query = sqlalchemyutils.model_query(
|
||||
model, session, args, **kwargs)
|
||||
@ -216,14 +211,15 @@ class Connection(api.Connection):
|
||||
|
||||
def instance_destroy(self, context, instance_id):
|
||||
with _session_for_write():
|
||||
query = model_query(context, models.Instance, instance=True)
|
||||
query = model_query(context, models.Instance)
|
||||
query = add_identity_filter(query, instance_id)
|
||||
count = query.soft_delete()
|
||||
|
||||
nics_query = model_query(context, models.InstanceNic).filter_by(
|
||||
instance_uuid=instance_id)
|
||||
nics_query.delete()
|
||||
count = query.delete()
|
||||
if count != 1:
|
||||
raise exception.InstanceNotFound(instance=instance_id)
|
||||
instance_nics = model_query(context, models.InstanceNic).filter_by(
|
||||
instance_uuid=instance_id)
|
||||
instance_nics.delete()
|
||||
|
||||
def instance_update(self, context, instance_id, values):
|
||||
if 'uuid' in values:
|
||||
|
@ -84,10 +84,7 @@ class Instance(Base):
|
||||
image_uuid = Column(String(36), nullable=True)
|
||||
node_uuid = Column(String(36), nullable=True)
|
||||
launched_at = Column(DateTime, nullable=True)
|
||||
deleted_at = Column(DateTime, nullable=True)
|
||||
extra = Column(db_types.JsonEncodedDict)
|
||||
deleted = Column(Boolean, default=False)
|
||||
|
||||
locked = Column(Boolean)
|
||||
locked_by = Column(Enum('owner', 'admin'))
|
||||
|
||||
|
@ -406,7 +406,6 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
do_delete_instance(instance)
|
||||
|
||||
instance.power_state = states.NOSTATE
|
||||
instance.deleted_at = timeutils.utcnow()
|
||||
utils.process_event(fsm, instance, event='done')
|
||||
instance.destroy()
|
||||
|
||||
|
@ -53,8 +53,6 @@ class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
'node_uuid': object_fields.UUIDField(nullable=True),
|
||||
'launched_at': object_fields.DateTimeField(nullable=True),
|
||||
'extra': object_fields.FlexibleDictField(nullable=True),
|
||||
'deleted': object_fields.BooleanField(default=False),
|
||||
'deleted_at': object_fields.DateTimeField(nullable=True),
|
||||
'locked': object_fields.BooleanField(default=False),
|
||||
'locked_by': object_fields.StringField(nullable=True),
|
||||
}
|
||||
@ -148,9 +146,6 @@ class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
|
||||
def create(self, context=None):
|
||||
"""Create a Instance record in the DB."""
|
||||
values = self.obj_get_changes()
|
||||
# Since we need to avoid passing False down to the DB layer
|
||||
# (which uses an integer), we can always default it to zero here.
|
||||
values['deleted'] = 0
|
||||
instance_nics = values.pop('nics', None)
|
||||
if instance_nics:
|
||||
values['nics'] = instance_nics.as_list_of_dict()
|
||||
|
@ -58,9 +58,7 @@ def get_test_instance(**kw):
|
||||
'node_uuid': kw.get('node_uuid',
|
||||
'f978ef48-d4af-4dad-beec-e6174309bc71'),
|
||||
'launched_at': kw.get('launched_at'),
|
||||
'deleted_at': kw.get('deleted_at'),
|
||||
'extra': kw.get('extra', {}),
|
||||
'deleted': kw.get('deleted', False),
|
||||
'updated_at': kw.get('updated_at'),
|
||||
'created_at': kw.get('created_at'),
|
||||
'locked': kw.get('locked', False),
|
||||
|
@ -382,7 +382,7 @@ class _TestObject(object):
|
||||
# version bump. It is md5 hash of object fields and remotable methods.
|
||||
# The fingerprint values should only be changed if there is a version bump.
|
||||
expected_object_fingerprints = {
|
||||
'Instance': '1.0-18d0ffc894a0f6b52df73a29919c035b',
|
||||
'Instance': '1.0-a4d843f506946e824fe6accb842e0a84',
|
||||
'ComputeNode': '1.0-36221253681d9acb88efe2a9113071c7',
|
||||
'ComputeNodeList': '1.0-33a2e1bb91ad4082f9f63429b77c1244',
|
||||
'ComputePort': '1.0-bdba0f3ece31260c4deea37d39618c1a',
|
||||
|
Loading…
Reference in New Issue
Block a user