-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
monitoring manager building to endpoint
- Loading branch information
Ari Zellner
committed
Dec 24, 2017
1 parent
474010f
commit bb88857
Showing
2 changed files
with
30 additions
and
10 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,18 +1,25 @@ | ||
module HasMonitoringManagerMixin | ||
extend ActiveSupport::Concern | ||
|
||
private | ||
def build_monitoring_manager_with_params | ||
monitoring_manager = build_monitoring_manager(:parent_manager => self, | ||
:name => "#{name} Monitoring Manager", | ||
:zone_id => zone_id, | ||
:provider_region => provider_region) | ||
monitoring_manager | ||
end | ||
|
||
def endpoint_created(role) | ||
if role == "prometheus_alerts" && monitoring_manager.nil? | ||
monitoring_manager = build_monitoring_manager_with_params | ||
monitoring_manager.save | ||
end | ||
end | ||
|
||
def ensure_monitoring_manager | ||
# monitoring_manager should be defined by child classes. | ||
if monitoring_manager_needed? && monitoring_manager.nil? | ||
build_monitoring_manager(:parent_manager => self) | ||
monitoring_manager.name = "#{name} Monitoring Manager" | ||
monitoring_manager.zone_id = zone_id | ||
monitoring_manager.provider_region = provider_region | ||
elsif !monitoring_manager_needed? && monitoring_manager.present? | ||
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.delete_queue | ||
monitoring_manager.destroy_queue | ||
end | ||
end | ||
end |