Skip to content
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

Merged
merged 4 commits into from
Jan 4, 2018

Conversation

zeari
Copy link

@zeari zeari commented Dec 11, 2017

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


def ensure_monitoring_manager_deletion
monitoring_manager.try(:delete_queue) unless try(:monitoring_manager_needed?)
end
Copy link
Author

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.

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?

Copy link
Member

@yaacov yaacov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@moolitayer
Copy link

@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?)
Copy link
Contributor

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?

Copy link
Author

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.

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?

@zeari
Copy link
Author

zeari commented Dec 14, 2017

@bazulay @moolitayer gaprindashvili/yes?

@zeari zeari force-pushed the monitoring_manager_deletion branch from de77506 to 25ab150 Compare December 14, 2017 12:55
@zeari
Copy link
Author

zeari commented Dec 14, 2017

@cben @moolitayer I unified the functionality of creation\deletion under before_save

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?)
Copy link
Member

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?

Copy link
Author

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

@zeari zeari force-pushed the monitoring_manager_deletion branch from 25ab150 to 84505b7 Compare December 14, 2017 13:09
@moolitayer
Copy link

@bazulay @moolitayer gaprindashvili/yes?

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.

Copy link

@moolitayer moolitayer left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two : -)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeari 👍 for comments!!

@zeari zeari force-pushed the monitoring_manager_deletion branch from 84505b7 to a0a6cb0 Compare December 17, 2017 09:39
@yaacov
Copy link
Member

yaacov commented Dec 17, 2017

👍 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.
Copy link
Contributor

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.

Copy link

@moolitayer moolitayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove ack

@zeari zeari force-pushed the monitoring_manager_deletion branch from a0a6cb0 to cd86fb3 Compare December 21, 2017 16:50
@zeari
Copy link
Author

zeari commented Dec 21, 2017

I moved some code to endpoint.rb

@miq-bot add_label wip

@miq-bot miq-bot changed the title ensure monitoring manager deletion and creation on provider update [WIP] ensure monitoring manager deletion and creation on provider update Dec 21, 2017
@miq-bot miq-bot added the wip label Dec 21, 2017
monitoring_manager = ems.try(:monitoring_manager)

# Make sure monitoring manager is deleted\created for the prometheus endpoint
if role == "prometheus_alerts" && monitoring_manager.nil?
Copy link
Contributor

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)

@zeari zeari force-pushed the monitoring_manager_deletion branch from cd86fb3 to b38e8e7 Compare December 24, 2017 10:24
@zeari
Copy link
Author

zeari commented Dec 24, 2017

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] ensure monitoring manager deletion and creation on provider update ensure monitoring manager deletion and creation on provider update Dec 24, 2017
@miq-bot miq-bot removed the wip label Dec 24, 2017
@zeari
Copy link
Author

zeari commented Dec 24, 2017

Still doesnt work with the API

@miq-bot add_label wip

@miq-bot miq-bot changed the title ensure monitoring manager deletion and creation on provider update [WIP] ensure monitoring manager deletion and creation on provider update Dec 24, 2017
@zeari zeari force-pushed the monitoring_manager_deletion branch from b38e8e7 to 6d60e97 Compare December 24, 2017 13:36
@moolitayer
Copy link

This DOES work with the API.
@moolitayer ManageIQ/manageiq-providers-kubernetes#188 (comment)
The role is prometheus_alerts instead of prometheus-alerts (underscore and not dash)

Nice catch, updated!

@zeari zeari force-pushed the monitoring_manager_deletion branch from 6d60e97 to bb88857 Compare December 24, 2017 13:51
@zeari
Copy link
Author

zeari commented Dec 25, 2017

This PR and ManageIQ/manageiq-providers-kubernetes#188 need to be merged together.
I ran the failed travis tests locally against ManageIQ/manageiq-providers-kubernetes#188 and didnt get any failures.

Copy link
Contributor

@cben cben left a 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.
Copy link
Contributor

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.

Copy link
Author

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.

@zeari
Copy link
Author

zeari commented Dec 25, 2017

@bazulay @moolitayer gaprindashvili/yes?

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.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1528955
@miq-bot add_label gaprindashvili/yes

@zeari zeari force-pushed the monitoring_manager_deletion branch from bb88857 to 79c12d5 Compare December 25, 2017 13:51
Copy link

@moolitayer moolitayer left a 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

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. we can keep the old name
  2. cant be private since we access this through Endpoint

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, sure.

@zeari
Copy link
Author

zeari commented Dec 28, 2017

I think ensure_monitoring_manager_with_params should be private and endpoint_created/endpoint_destroyed should be public, right?

@moolitayer keeping ensure_monitoring_manager made the tests pass 😄

@zeari zeari changed the title ensure monitoring manager deletion and creation on provider update ensure monitoring manager deletion and creation on endpoint update Jan 4, 2018
@zeari
Copy link
Author

zeari commented Jan 4, 2018

@agrare PTAL

after_destroy :endpoint_destroyed

def endpoint_created
# Make sure monitoring manager is created for the prometheus endpoint
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, removing.

@agrare agrare self-assigned this Jan 4, 2018
Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice change @zeari

@agrare
Copy link
Member

agrare commented Jan 4, 2018

Thanks @zeari will merge when green

@miq-bot
Copy link
Member

miq-bot commented Jan 4, 2018

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
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@agrare agrare merged commit 272f1e6 into ManageIQ:master Jan 4, 2018
@agrare agrare added this to the Sprint 77 Ending Jan 15, 2018 milestone Jan 4, 2018
@agrare agrare added the bug label Jan 4, 2018
simaishi pushed a commit that referenced this pull request Jan 4, 2018
ensure monitoring manager deletion and creation on endpoint update
(cherry picked from commit 272f1e6)

https://bugzilla.redhat.com/show_bug.cgi?id=1531293
@simaishi
Copy link
Contributor

simaishi commented Jan 4, 2018

Gaprindashvili backport details:

$ git log -1
commit 47636cae5e62b274fd7987f23b5dab884eb7f0e1
Author: Adam Grare <agrare@redhat.com>
Date:   Thu Jan 4 10:23:26 2018 -0500

    Merge pull request #16635 from zeari/monitoring_manager_deletion
    
    ensure monitoring manager deletion and creation on endpoint update
    (cherry picked from commit 272f1e638b984a9620b51293f9379c16ca9c31ee)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1531293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants