-
Notifications
You must be signed in to change notification settings - Fork 898
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
ensure monitoring manager deletion and creation on endpoint update #16635
Conversation
|
||
def ensure_monitoring_manager_deletion | ||
monitoring_manager.try(:delete_queue) unless try(:monitoring_manager_needed?) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theres a slight issue here. If a user tries to recreate the alerts endpoint while the previous manager wasnt deleted yet, he could end up with the endpoint but without a manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could fail the save if monitoring_manager.enabled = false
to reduce the chance of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@masayag since you are doing something similar in case this is helpful |
monitoring_manager.zone_id = zone_id | ||
monitoring_manager.provider_region = provider_region | ||
end | ||
end | ||
|
||
def ensure_monitoring_manager_deletion | ||
monitoring_manager.try(:delete_queue) unless try(:monitoring_manager_needed?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if try(:monitoring_manager_needed?)
fails — if it doesn't respond to such method — is it correct to delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the openshift provider is the only one who uses the monitoring manager so its up to us. As best as i can tell, yes. Because if you dont have the endpoint\role for monitoring then you dont need the manager.
We wont lose data the collected since the MiqAlerts
are associated with the parent ems and not this manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes these should only be called for container managers, and they all implement monitoring_manager_needed?
since it's in container manager mixin. I suspect this was only done to allow merging the manageiq PR first with out breaking anything. @zeari can we loose the try?
@bazulay @moolitayer gaprindashvili/yes? |
de77506
to
25ab150
Compare
@cben @moolitayer I unified the functionality of creation\deletion under |
monitoring_manager.zone_id = zone_id | ||
monitoring_manager.provider_region = provider_region | ||
elsif try(:monitoring_manager_needed?) == false && monitoring_manager.present? | ||
monitoring_manager.try(:delete_queue) unless try(:monitoring_manager_needed?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need the unless
here based on the condition above, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Youre right. I was moving stuff around with @moolitayer
25ab150
to
84505b7
Compare
I think so, according to your input this bug would completely prevent monitoring from working if the endpoint isn't added on container manager creation. Please create a bz for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
monitoring_manager.zone_id = zone_id | ||
monitoring_manager.provider_region = provider_region | ||
elsif !monitoring_manager_needed? && monitoring_manager.present? | ||
# TODO:: if someone deletes the alerts endpoint and then quickly readds it they can end up without a manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two :
-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zeari 👍 for comments!!
84505b7
to
a0a6cb0
Compare
👍 nice! |
monitoring_manager.zone_id = zone_id | ||
monitoring_manager.provider_region = provider_region | ||
elsif !monitoring_manager_needed? && monitoring_manager.present? | ||
# TODO: if someone deletes the alerts endpoint and then quickly readds it they can end up without a manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I don't see any easy fix, and hard fixes are out of scope.
I wonder if long-term we'll want API & UI to actually create/delete managers — and deal with manager deletion being async — rather than just creating/deleting endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ack
a0a6cb0
to
cd86fb3
Compare
I moved some code to @miq-bot add_label wip |
app/models/endpoint.rb
Outdated
monitoring_manager = ems.try(:monitoring_manager) | ||
|
||
# Make sure monitoring manager is deleted\created for the prometheus endpoint | ||
if role == "prometheus_alerts" && monitoring_manager.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
To keep Endpoint class mostly provider-agnostic, consider keeping the logic in HasMonitoringManagerMixin method(s), with the hooks here reduced to something like
ems.endpoint_created(role) if ems.responds_to?(:endpoint_created)
cd86fb3
to
b38e8e7
Compare
@miq-bot remove_label wip |
Still doesnt work with the API @miq-bot add_label wip |
b38e8e7
to
6d60e97
Compare
Nice catch, updated! |
6d60e97
to
bb88857
Compare
This PR and ManageIQ/manageiq-providers-kubernetes#188 need to be merged together. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
monitoring_manager.provider_region = provider_region | ||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this is a real risk. I think the queued destroy will be targeted to a specific manager id, and not affect the new monitoring manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, even less of a risk now that the logic moved to endpoint.rb
.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1528955 |
bb88857
to
79c12d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -1,21 +1,28 @@ | |||
module HasMonitoringManagerMixin | |||
extend ActiveSupport::Concern | |||
|
|||
private | |||
def ensure_monitoring_manager_with_params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the old name better. also why not keep private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we can keep the old name
- cant be private since we access this through
Endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ensure_monitoring_manager_with_params should be private and endpoint_created/endpoint_destroyed should be public, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sure.
@moolitayer keeping |
@agrare PTAL |
app/models/endpoint.rb
Outdated
after_destroy :endpoint_destroyed | ||
|
||
def endpoint_created | ||
# Make sure monitoring manager is created for the prometheus endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a generic callback that could be used for other things I don't think you need to call out the monitoring manager or prometheus endpoint specifically here and here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, removing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice change @zeari
Thanks @zeari will merge when green |
Checked commits zeari/manageiq@474010f~...8f771b9 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
ensure monitoring manager deletion and creation on endpoint update (cherry picked from commit 272f1e6) https://bugzilla.redhat.com/show_bug.cgi?id=1531293
Gaprindashvili backport details:
|
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1528955
Updating the monitoring endpoint on an existing provider did not create or delete the monitoring manager accordingly.
Completed by ManageIQ/manageiq-providers-kubernetes#188
@moolitayer @cben @nimrodshn @yaacov Please review
@miq-bot add_label providers/containers