Skip to content
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

Update stop_event_monitor_queue_on_change to take changes #832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions app/models/manageiq/providers/openstack/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module ManageIQ::Providers::Openstack::ManagerMixin
include ManageIQ::Providers::Openstack::HelperMethods

included do
after_save :stop_event_monitor_queue_on_change
before_destroy :stop_event_monitor
end

Expand Down Expand Up @@ -263,21 +262,20 @@ def event_monitor_available?
false
end

def stop_event_monitor_queue_on_change
if event_monitor_class && !self.new_record? && (authentications.detect{ |x| x.previous_changes.present? } ||
endpoints.detect{ |x| x.previous_changes.present? })
def stop_event_monitor_queue_on_change(_changes)
if event_monitor_class && !new_record?
_log.info("EMS: [#{name}], Credentials or endpoints have changed, stopping Event Monitor. It will be restarted by the WorkerMonitor.")
stop_event_monitor_queue
network_manager.stop_event_monitor_queue if try(:network_manager) && !network_manager.new_record?
cinder_manager.stop_event_monitor_queue if try(:cinder_manager) && !cinder_manager.new_record?
end
end

def stop_event_monitor_queue_on_credential_change
def stop_event_monitor_queue_on_credential_change(changes)
# TODO(lsmola) this check should not be needed. Right now we are saving each individual authentication and
# it is breaking the check for changes. We should have it all saved by autosave when saving EMS, so the code
# for authentications needs to be rewritten.
stop_event_monitor_queue_on_change
stop_event_monitor_queue_on_change(changes)
end

def translate_exception(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ def allow_targeted_refresh?
true
end

def stop_event_monitor_queue_on_change
if !self.new_record? && parent_manager && (authentications.detect{ |x| x.previous_changes.present? } ||
endpoints.detect{ |x| x.previous_changes.present? })
def stop_event_monitor_queue_on_change(_changes)
if !self.new_record? && parent_manager
_log.info("EMS: [#{name}], Credentials or endpoints have changed, stopping Event Monitor. It will be restarted by the WorkerMonitor.")
stop_event_monitor_queue
end
Expand Down