Skip to content

Commit

Permalink
Update stop_event_monitor_queue_on_change to take changes
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jun 19, 2023
1 parent 2c80b16 commit 714cf7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
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

0 comments on commit 714cf7a

Please sign in to comment.