Skip to content

Commit

Permalink
orchestrate destroy of dependent managers
Browse files Browse the repository at this point in the history
With orchestrated destroy of managers we wait until all workers
are shutdown before actually destroying the ems.

This means, all dependent workers, like network_manager, must
be destroyed as well before we can destroy the cloud manager

This queues up destroy of all child_managers
  • Loading branch information
durandom committed Aug 30, 2017
1 parent bf64a63 commit 756d5b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,16 +432,14 @@ def enable!
update!(:enabled => true)
end

# override destroy_queue from AsyncDeleteMixin
def self.destroy_queue(ids)
ids = Array.wrap(ids)
_log.info("Queuing destroy of #{name} with the following ids: #{ids.inspect}")
ids.each do |id|
schedule_destroy_queue(id)
end
find(Array.wrap(ids)).each(&:destroy_queue)
end

# override destroy_queue from AsyncDeleteMixin
def destroy_queue
_log.info("Queuing destroy of #{self.class.name} with id: #{id}")
child_managers.each(&:destroy_queue)
self.class.schedule_destroy_queue(id)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@
ems.destroy
expect(ExtManagementSystem.count).to eq(1)
end

it "queues up destroy for child_managers" do
child_manager = FactoryGirl.create(:ext_management_system)
ems = FactoryGirl.create(:ext_management_system, :child_managers => [child_manager])
expect(described_class).to receive(:schedule_destroy_queue).with(ems.id)
expect(described_class).to receive(:schedule_destroy_queue).with(child_manager.id)
described_class.destroy_queue(ems.id)
end
end

context "virtual column :supports_block_storage" do
Expand Down

0 comments on commit 756d5b3

Please sign in to comment.