forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#16635 from zeari/monitoring_manager_deletion
ensure monitoring manager deletion and creation on endpoint update
- Loading branch information
Showing
2 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
module HasMonitoringManagerMixin | ||
extend ActiveSupport::Concern | ||
|
||
private | ||
def endpoint_created(role) | ||
if role == "prometheus_alerts" && monitoring_manager.nil? | ||
monitoring_manager = ensure_monitoring_manager | ||
monitoring_manager.save | ||
end | ||
end | ||
|
||
def ensure_monitoring_manager | ||
# monitoring_manager should be defined by child classes. | ||
if try(:monitoring_manager_needed?) | ||
build_monitoring_manager(:parent_manager => self) | ||
monitoring_manager.name = "#{name} Monitoring Manager" | ||
def endpoint_destroyed(role) | ||
if role == "prometheus_alerts" && monitoring_manager.present? | ||
# TODO: if someone deletes the alerts endpoint and then quickly readds it they can end up without a manager. | ||
monitoring_manager.destroy_queue | ||
end | ||
ensure_monitoring_manager_properties | ||
end | ||
|
||
def ensure_monitoring_manager_properties | ||
if monitoring_manager | ||
monitoring_manager.zone_id = zone_id | ||
monitoring_manager.provider_region = provider_region | ||
private | ||
|
||
def ensure_monitoring_manager | ||
if monitoring_manager.nil? | ||
build_monitoring_manager(:parent_manager => self, | ||
:name => "#{name} Monitoring Manager", | ||
:zone_id => zone_id, | ||
:provider_region => provider_region) | ||
end | ||
|
||
monitoring_manager | ||
end | ||
end |