From 714cf7ac19778dd2bee7680ae852f26522e3d7a6 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Wed, 7 Dec 2022 13:11:30 -0500 Subject: [PATCH] Update stop_event_monitor_queue_on_change to take changes --- .../manageiq/providers/openstack/manager_mixin.rb | 10 ++++------ .../openstack/storage_manager/cinder_manager.rb | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/models/manageiq/providers/openstack/manager_mixin.rb b/app/models/manageiq/providers/openstack/manager_mixin.rb index d81aca81e..b390634d3 100644 --- a/app/models/manageiq/providers/openstack/manager_mixin.rb +++ b/app/models/manageiq/providers/openstack/manager_mixin.rb @@ -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 @@ -263,9 +262,8 @@ 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? @@ -273,11 +271,11 @@ def stop_event_monitor_queue_on_change 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) diff --git a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb index 29ce4cb2b..ca16a20e6 100644 --- a/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb +++ b/app/models/manageiq/providers/openstack/storage_manager/cinder_manager.rb @@ -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