Skip to content

Commit

Permalink
Merge pull request ManageIQ#14038 from Ladas/fix_deletion_of_object_s…
Browse files Browse the repository at this point in the history
…torage_objects_that_creates_zombies

Fix deletion of object storage objects that creates zombies
  • Loading branch information
roliveri authored Feb 23, 2017
2 parents 2d2f124 + debbc0e commit 489bf7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions app/models/cloud_object_store_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@ class CloudObjectStoreObject < ApplicationRecord
acts_as_miq_taggable

alias_attribute :name, :key

def disconnect_inv
# This is for bypassing a weird Rails behaviour. If we do a ems.cloud_object_store_objects.delete(objects) and a
# relation in the ems is missing a :dependent => :destroy on :cloud_object_store_objects relation, it does not
# delete any records. The :dependent => :destroy was removed by https://github.com/ManageIQ/manageiq/pull/14009
#
# Method disconnect_inv is called on each record separately, so it will destroy records as expected.
# The fact that refresh deletes a non existent records from our DB is tested by AWS S3 stubbed specs.
#
# TODO(lsmola) investigate rails weird behavior, write a reproducer and delete this when fixed. Unless this is an
# expected behaviour.
destroy
end
end
2 changes: 1 addition & 1 deletion app/models/ems_refresh/save_inventory_object_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def save_object_storage_cloud_object_store_objects_inventory(ems, hashes, target
h[:cloud_object_store_container_id] = h.fetch_path(:container, :id)
end

save_inventory_multi(ems.cloud_object_store_objects, hashes, deletes, [:ems_ref], nil, [:tenant, :container])
save_inventory_multi(ems.cloud_object_store_objects, hashes, deletes, [:ems_ref], nil, [:tenant, :container], true)
store_ids_for_new_records(ems.cloud_object_store_objects, hashes, :ems_ref)
end
end

0 comments on commit 489bf7c

Please sign in to comment.