-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
orchestrate destroy of dependent managers #15590
Conversation
e346e05
to
bfdb363
Compare
app/models/ext_management_system.rb
Outdated
@@ -26,6 +26,8 @@ def self.supported_types_and_descriptions_hash | |||
end | |||
|
|||
belongs_to :provider | |||
has_many :child_managers, :class_name => 'ExtManagementSystem', :foreign_key => 'parent_ems_id' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called this child_managers
(which is the opposite of parent_manager)
Although I'd like e.g. dependent_managers
better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope i'm not missing context here
We have several different child managers in the system. They are currently available through ext.monitoring_manager
ext.network_manager
etc.
It's a good idea to treat them all the same way here. Maybe we can define the relation based on parent_ems_id that they all should have?
cc @Ladas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can define the relation based on parent_ems_id that they all should have?
@moolitayer I dont understand. All child managers are linked via the parent_ems_id
, so it will catch all, monitoring, network, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just having the child_managers relation will not hurt, since it's just another way to query it(we will still use ext.monitoring_manager and ext.network_manager where needed). But I am not sure if the cascade delete should work the same for all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh looks good @durandom I must have missed the :foreign_key
definitions there.
@blomquisg does it make sense from a UI / Business perspective to delete all dependent managers? Could we have a case where the cloudmanager is about to be deleted, but e.g. a storage manger should be kept? |
I dont think so, but i could be wrong. I would solve this by changing the relation to cc @moolitayer |
this is already the case, via e.g. the has_network_manager_mixin. @zeari why not calling |
This way should work fine. |
@blomquisg could you have a look if that makes sense from a user perspective? |
@agrare could you have a look at this one? |
app/models/ext_management_system.rb
Outdated
@@ -442,6 +444,9 @@ def self.schedule_destroy_queue(id, deliver_on = nil) | |||
:method_name => "orchestrate_destroy", | |||
:deliver_on => deliver_on, | |||
) | |||
find(id).child_managers.each do |child_manager| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about doing this in the instance method so you can skip the find(id)
and just have access to child_managers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would think def destroy_queue
is called, but alas not The UI calls it on the model. And as the instance method also forwards it to the class method, it's safer to do it here.
app/models/ext_management_system.rb
Outdated
@@ -442,6 +444,9 @@ def self.schedule_destroy_queue(id, deliver_on = nil) | |||
:method_name => "orchestrate_destroy", | |||
:deliver_on => deliver_on, | |||
) | |||
find(id).child_managers.each do |child_manager| | |||
child_manager.destroy_queue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do need to do this here should we honor the deliver_on
for the child managers as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, thinking about it: The canonical entrypoint seems to be self.destroy_queue
or the instance version. And there is no deliver_on
. The deliver_on is only used by orchestrate_destroy
to throttle. So, I'd actually leave it like this?!
But I can change it if you think it's better for eventualities or consistency...
45c8fde
to
4877c7e
Compare
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
4877c7e
to
756d5b3
Compare
@agrare please have a look again. |
Checked commit durandom@756d5b3 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
FWIW, looks good to me. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks a lot cleaner @durandom nice!
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
I introduce a child_manager association and queues up a destroy of all child_managers
#14848
@cben @Ladas @jrafanie