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

Improve Targeted Refresh for Cloud and Network managers #175

Merged
merged 5 commits into from
Jan 10, 2018

Conversation

mansam
Copy link
Contributor

@mansam mansam commented Dec 7, 2017

https://bugzilla.redhat.com/show_bug.cgi?id=1519214

I'm basing the events I catch on ceilometer event definitions, but I'm not sure that I have a complete list. @aufi, do you know if there is a better source than https://github.com/openstack/ceilometer/blob/master/ceilometer/pipeline/data/event_definitions.yaml ?

@miq-bot miq-bot added the wip label Dec 7, 2017
# @param ems_event [EmsEvent] EmsEvent object
# @return [Array] Array of ManagerRefresh::Target objects
def parse_ems_event_targets(ems_event)
target_collection = ManagerRefresh::TargetCollection.new(:manager => ems_event.ext_management_system, :event => ems_event)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, the separate event catcher for network manager complicates stuff.

I think we need to set here parent_manager:
ManagerRefresh::TargetCollection.new(:manager => ems_event.ext_management_system.parent_manager, :event => ems_event)

Since all of the targeted refresh runs in the cloud manager and the targets are bucketed based on manager. Storage wise, this doesn't matter, since each persistor assigns the right manager for saving. So this is more for which ems and therefore worker should process it.

@Ladas
Copy link
Contributor

Ladas commented Dec 8, 2017

@mansam so for /System/event_handlers/refresh in automate to work (to parse some targets and send them for refresh), we need to cover all events listed in https://github.com/Ladas/manageiq-content/tree/33e254dd0fcc2e47f379130f8dcf21b51ab30e10/content/automate/ManageIQ/System/Event/EmsEvent/OpenStack.class

But if we could base it on generic definition like https://github.com/openstack/ceilometer/blob/master/ceilometer/pipeline/data/event_definitions.yaml, that would be awesome. That would mean it will work for more events than defined in our automate.

@mansam
Copy link
Contributor Author

mansam commented Dec 8, 2017

@Ladas @aufi The list of events from manageiq-content is very helpful, but unfortunately I'm not sure it's sufficient. If I understand correctly, we capture events from Ceilometer, and Ceilometer changes the format of the events from the actual services quite a bit. Without more detail about the actual event definitions we get from Ceilometer it's not really possible to parse the events (since I don't know what fields are available, and they are not consistently named), and not every event in manageiq-content has an equivalent in the default Ceilometer event definition yaml. I've done a lot of looking over the past couple days and in the past when first working on this and am coming up empty handed for better documentation.

(as a concrete example-- what are the fields on the aggregate.*.* events after they pass through Ceilometer?)

@mansam mansam force-pushed the event-target-parser-network-manager branch from a202ee8 to e016c56 Compare December 8, 2017 20:49
@Ladas
Copy link
Contributor

Ladas commented Dec 8, 2017

@mansam right so, AWS has no docs for the event payloads, so what I ended up doing was

+++ b/app/models/manageiq/providers/amazon/cloud_manager/event_catcher/stream.rb
@@ -190,6 +190,13 @@ class ManageIQ::Providers::Amazon::CloudManager::EventCatcher::Stream
       return
     end
 
+    ####
+    File.open(Rails.root.join("events", event["eventType"]+".json" ), "w") do |file|
+      file.write(message.body)
+    end
+    ####
+
+
     $log.info("#{log_header} Found SNS Message with message type #{event["eventType"]} coming from #{event[:event_source]}")

Then I was clicking around, recording the real events. Then I am using the payload of the real events for the specs, to make sure I am parsing the right targets. Also, for CloudWatch events, the ids are in a form of "instance_id, image_id", so I don't even care what kind of event it is. Any event referencing instance_id, will produce VM target.


So yeah, if the event payloads are different in AMQP/Ceilometer/WhatIsTheNewServiceName, than this kind of sucks.

The AWS has similar issue, sometimes the event has VpcID, other times vpcId https://github.com/Ladas/manageiq-providers-amazon/blob/4c66893fd1a91dc5fd3aa259a7c0ddd044c65576/app/models/manageiq/providers/amazon/cloud_manager/event_target_parser.rb#L96

@mansam
Copy link
Contributor Author

mansam commented Dec 9, 2017

@Ladas Hrm, good point that if the IDs are named in a recognizable fashion then it doesn't matter at all what event it came from.

@mansam mansam force-pushed the event-target-parser-network-manager branch 2 times, most recently from 5875a5e to 4209c87 Compare December 11, 2017 21:09
@mansam mansam changed the title [wip] Implement EventTargetParser for NetworkManager Implement EventTargetParser for NetworkManager Dec 13, 2017
@miq-bot miq-bot removed the wip label Dec 13, 2017
@miq-bot
Copy link
Member

miq-bot commented Dec 13, 2017

This pull request is not mergeable. Please rebase and repush.

@mansam mansam force-pushed the event-target-parser-network-manager branch from b401bf4 to 6ba0a3b Compare December 14, 2017 00:01
@mansam mansam changed the title Implement EventTargetParser for NetworkManager [wip] Implement EventTargetParser for NetworkManager Dec 14, 2017
@mansam mansam changed the title [wip] Implement EventTargetParser for NetworkManager [wip] Improve Targeted Refresh for Cloud and Network managers Dec 14, 2017
@miq-bot miq-bot added wip and removed unmergeable labels Dec 14, 2017
@mansam mansam force-pushed the event-target-parser-network-manager branch 2 times, most recently from fc910da to 4437dd7 Compare December 20, 2017 21:44
@mansam mansam changed the title [wip] Improve Targeted Refresh for Cloud and Network managers Improve Targeted Refresh for Cloud and Network managers Dec 21, 2017
@miq-bot miq-bot removed the wip label Dec 21, 2017
@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2018

This pull request is not mergeable. Please rebase and repush.

@blomquisg
Copy link
Member

@mansam, can you rebase and repush?

@mansam mansam force-pushed the event-target-parser-network-manager branch from 4437dd7 to 9b4dbfd Compare January 5, 2018 19:01
@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2018

Some comments on commits mansam/manageiq-providers-openstack@6a91a7e~...9b4dbfd

spec/models/manageiq/providers/openstack/cloud_manager/event_target_parser_spec.rb

  • ⚠️ - 6 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

spec/models/manageiq/providers/openstack/network_manager/event_target_parser_spec.rb

  • ⚠️ - 6 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Jan 5, 2018

Checked commits mansam/manageiq-providers-openstack@6a91a7e~...9b4dbfd with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
37 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

@mansam
Copy link
Contributor Author

mansam commented Jan 5, 2018

@blomquisg updated

@blomquisg
Copy link
Member

@Ladas, do you still have outstanding changes you're looking for? If not, can you clear/change your review?

ManageIQ::Providers::Openstack::CloudManager::RefreshParser.ems_inv_to_hashes(ems, refresher_options)
end

class Openstack::CloudManager::Refresher < ManageIQ::Providers::BaseManager::ManagerRefresher
def save_inventory(ems, target, inventory_collections)
super
EmsRefresh.queue_refresh(ems.network_manager) if target.kind_of?(ManageIQ::Providers::BaseManager)
EmsRefresh.queue_refresh(ems.cinder_manager) if target.kind_of?(ManageIQ::Providers::BaseManager)
Copy link
Contributor

Choose a reason for hiding this comment

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

so maybe, we will have to do a cinder full refresh always here, we should track that as a separate issue though

@@ -3,15 +3,15 @@ module Openstack
module RefreshParserCommon
module HelperMethods
def openstack_admin?
::Settings.ems.ems_refresh.openstack.try(:is_admin)
::Settings.ems_refresh.openstack.try(:is_admin)
Copy link
Contributor

Choose a reason for hiding this comment

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

a nit for other PR probably:

we usually abstract ::Settings.ems_refresh.openstack as a method , in new refresh parser it available on collector https://github.com/Ladas/manageiq/blob/b9e6b294604d744f59e3bf270e16264f067fb85a/app/models/manager_refresh/inventory/collector.rb#L11

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that it should be abstracted out in the future.

@@ -49,16 +49,16 @@

assert_common
end
::Settings.ems.ems_refresh.openstack.is_admin = false
::Settings.ems.ems_refresh.openstack_network.is_admin = false
::Settings.ems_refresh.openstack.is_admin = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

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

Looks good overall. 👍

@mansam I have commented several nits though, that should be fixed in other PRs.

Also for other PRs, seems like we are mostly doing API query for 1 target, so we should talk about how to optimize that and probably set upper limit of targets for now, before we would switch to full refresh. (we do not need it for AWS since there is 1 API for N targets)

Also, it's good to read the targeted VCRs to verify it collects what it should. In targeted_vm I see we collect the same port several times. Also we fetch all subnets,
so API filtering probably doesn't work. (these are minor perf issues though)

@mansam
Copy link
Contributor Author

mansam commented Jan 9, 2018

@Ladas Thanks for the review. In the future for APIs that support filtering correctly, it might make sense to make a list request that is filtered by the desired IDs. Unfortunately filtering doesn't seem to be supported everywhere (like networking, it seems).

@aufi
Copy link
Member

aufi commented Jan 10, 2018

LGTM, merging!

@aufi aufi merged commit 92aed61 into ManageIQ:master Jan 10, 2018
@aufi aufi added this to the Sprint 77 Ending Jan 15, 2018 milestone Jan 10, 2018
simaishi pushed a commit that referenced this pull request Jan 10, 2018
Improve Targeted Refresh for Cloud and Network managers
(cherry picked from commit 92aed61)

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

Gaprindashvili backport details:

$ git log -1
commit 1c1ba1a8be210bbcfd109b777cedb89af0e507e7
Author: Marek Aufart <aufi.cz@gmail.com>
Date:   Wed Jan 10 10:06:54 2018 +0100

    Merge pull request #175 from mansam/event-target-parser-network-manager
    
    Improve Targeted Refresh for Cloud and Network managers
    (cherry picked from commit 92aed61171736d5d96d11bbf25a609347d29727b)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1533225

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.

7 participants