Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Adaptations to have a working refresh for Hawkular's Inventory.next #10

Merged
merged 3 commits into from Apr 27, 2017

Conversation

israel-hdez
Copy link
Member

@israel-hdez israel-hdez commented Apr 17, 2017

Hawkular's inventory is being rewritten to store its inventory as metrics. The hawkular-client-ruby is being modified to make the inventory's change as transparent as possible for users of the ruby client, but this is not fully possible. This PR deals with changes required in MiQ side to work correctly with new's Hawkular inventory.

Note: This PR was worked on top of code changes of #6. To view the relevant differences, look only at the last commit. #6 has been merged. Now, it this is rebased from master.

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

@miq-bot miq-bot added the wip label Apr 17, 2017
@pilhuhn
Copy link
Contributor

pilhuhn commented Apr 18, 2017

CC @abonas

@abonas
Copy link
Member

abonas commented Apr 18, 2017

@israel-hdez thanks for this! is this necessary to rely here on PR #6?

@abonas abonas requested a review from cfcosta April 18, 2017 10:17
@abonas
Copy link
Member

abonas commented Apr 18, 2017

cc @moolitayer @simon3z

Copy link
Contributor

@cfcosta cfcosta left a comment

Choose a reason for hiding this comment

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

There are some stuff that I think we need to change related to the mocks, the same as discussed on #6, but besides that it looks 🔥.

@@ -45,8 +45,11 @@ def config_data_for_resource(resource_path)
connection.inventory.get_config_data_for_resource(resource_path)
end

def metrics_for_metric_type(metric_path)
connection.inventory.list_metrics_for_metric_type(metric_path)
def metrics_for_metric_type(feed, metric_type_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd call this metrics_for_type, the second metric sounds redundant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now, it sounds redundant but, if needed, we may add metrics_for_resource_type or metrics_for_resource, turning ambiguous a metrics_for_type method. Could metrics_with_type be a better name?

# - Feed 1 has two deployments with ids: d1, d2
# - Feed 2 has three deployments with ids: d1, d2, d3, d4
parser.persister = double("Mocked persister")
deployments = []
Copy link
Contributor

Choose a reason for hiding this comment

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

You can have this as only one array declaration.

# - Feed 1 has one server with id: s1
# - Feed 2 has two servers ids: s1, s2
parser.persister = double("Mocked persister")
servers = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, just one array declaration.

collection.each do |item|
yield item, nil

path = CGI.unescape(item.model_class.try(:resource_path_for_metrics, item) || item.manager_uuid)
Copy link
Contributor

Choose a reason for hiding this comment

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

One detail that might be important is that CGI is not exactly related (meaning-wise) to what the PR is doing, and I think URI.unescape or URI.decode would be better. There are some tokens that parse differently on both methods, but I think it is worth a try to make the code less all-over-the-place.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. Since hawkular api is web-based, I'll change those CGI usages with URI.

@abonas
Copy link
Member

abonas commented Apr 18, 2017

@israel-hdez the above are the only changes needed accross all miq repos? no vcr cassettes need to be rerecorded? (tests of this PR pass so I wonder regarding cassettes)

@israel-hdez
Copy link
Member Author

israel-hdez commented Apr 18, 2017

@abonas

is this necessary to rely here on PR #6?

It depends on which PR gets merged first. If done separately, both PRs will have conflicting changes. I'm assuming that #6 will get merged first.

no vcr cassettes need to be rerecorded?

Yes! VCR cassettes need to be recorded again. Tests are passing, because travis is using the latest released hawkular-client gem, which works against current inventory. I will need some help here to know what was the setup used when VCR cassettes were first recorded, to recreate it and rerecord everything.

@simon3z
Copy link

simon3z commented Apr 18, 2017

@abonas the official hawkular-client gem version bump will happen on manageiq-gems-pending.gemspec, right?

@israel-hdez
Copy link
Member Author

@simon3z @abonas Is hawkular-client gem being used in another repo? Else, we may want to remove it from manageiq-gems-pending.gemspec and add it to manageiq-providers-hawkular.gemspec

@abonas
Copy link
Member

abonas commented Apr 19, 2017

@simon3z @abonas Is hawkular-client gem being used in another repo? Else, we may want to remove it from manageiq-gems-pending.gemspec and add it to manageiq-providers-hawkular.gemspec

@israel-hdez yes, it is used also by the containers provider which code currently resides in the main manageiq repo.
And regarding gem location - I also recently raised the topic of the gem declaration location - that it should not be in the gems pending gemfile). I 100% agree it's better to move it where you suggested (in a separate PR). @Fryguy @durandom ack?

@Fryguy
Copy link
Member

Fryguy commented Apr 19, 2017

@abonas Yes. The goal of manageiq-gems-pending is to not exist. Everything in there should be ripped out into it's own repo or, if provider specific, into the provider repo.

@durandom
Copy link
Member

it is used also by the containers provider which code currently resides in the main manageiq repo.

I suggest both, openshift, kubernetes and hawkular add it to their dependency in .gemspec then?!

@moolitayer
Copy link

I expect the gem to be used in:

  • manageiq-providers-kubernetes
  • manageiq-providers-openshift
  • manageiq-providers-hawkular
  • manageiq-providers-datawarehouse (does not exist but I understood it might exist in the future)

I suggest both, openshift, kubernetes and hawkular add it to their dependency in .gemspec then?!

if one repo bumps a version in a way that is not compatible with another (both cannot be satisfied)
wont we know about it in the main mangeiq repo only after the bump PR merge?

@miq-bot
Copy link
Member

miq-bot commented Apr 24, 2017

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

@durandom
Copy link
Member

if one repo bumps a version in a way that is not compatible with another (both cannot be satisfied)
wont we know about it in the main mangeiq repo only after the bump PR merge?

yes, it's the same with any other gem dependency

…rics

- Messaging types are now retrieved from its "type path" because the resources
  do not anymore include its resource-types.
- When collecting availability metrics, the "paths" are unescaped rather
  than escaped for string comparisons. This is because the paths received
  from hawkular are percent-encoded with arbitrary case and string
  comparisons were failing because some paths are using uppercase while
  others are using lowercase (e.g. '%2f' rather than '%2F').
@jkremser
Copy link
Member

jkremser commented Apr 26, 2017

@israel-hdez I can't run the refresh successfully.
I had to change the
/app/models/manageiq/providers/hawkular/inventory/parser/middleware_manager.rb:257 to use the nil? instead of .empty? because nil.empty? was causing exceptions and
in /app/models/manageiq/providers/hawkular/inventory/collector/middleware_manager.rb:52
there is still a call to method that has to be removed. Do you have any newer version that works?

EDIT: ignore my comment ^ I was using old version of hawkular-client gem :)

Disabling expectations testing the underlying container because they
require a more complex setup to work correctly. Will be re-enabled in a
follow-up commit.

Cassettes were recorded using the domain-mode example configuration for
WildFly 10.1.0.Final docker image.
@miq-bot
Copy link
Member

miq-bot commented Apr 26, 2017

Checked commits israel-hdez/manageiq-providers-hawkular@bed7634~...969f964 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks good. ⭐

@israel-hdez
Copy link
Member Author

This is working fine with v2.9.0 gem. So, I will un-wip it and let to you the decision to merge before or at the same time of ManageIQ/manageiq-gems-pending#138 is merged. It should not be merged "after" gems-pending PR because the refresh won't work. (Although, if merged "before", travis will stay red until the gems-pending PR is merged).

@cfcosta You may wand to do a quick re-review in the meanwhile.
@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] Adaptations to have a working refresh for Hawkular's Inventory.next Adaptations to have a working refresh for Hawkular's Inventory.next Apr 26, 2017
@miq-bot miq-bot removed the wip label Apr 26, 2017
@israel-hdez
Copy link
Member Author

@miq-bot assign abonas

@@ -30,19 +30,20 @@

# check whether the server was associated with the vm
server = @ems_hawkular.middleware_servers.first
expect(server.lives_on_id).to eql(@vm.id)
expect(server.lives_on_type).to eql(@vm.type)
# TODO: Restore these expectations
Copy link
Member Author

Choose a reason for hiding this comment

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

@Jiri-Kremser I will appreciate if you can instruct me how you did your setup for these expectations, so I can bring them back to life in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

They should appear if the hawkular-services are deployed on a virtual machine managed by RHEV provider and this provider is also added to MiQ. The cross-linking should just happen automatically. If I recall correctly the https://hawkular.torii.gva.redhat.com is running on RHEV and both the hawkular and RHEV can be added as providers to MiQ (juca can give you the access). Although, it will probably not work for the containerized hawular-services, because we no longer have the

sudo echo $HOSTNAME > /etc/machine-id

..in the start script, because the docker image must run without the root on openshift.

@jpkrohling As the author, could you pls check that I am not lying here :] Also, do you have any idea how to workaround the ^ for containers? Perhaps we can change the permissions of /etc/machine-id so that it's writable by non-root guys, right? That would work. If you are not against it I am willing to add it back.

Copy link
Contributor

Choose a reason for hiding this comment

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

They should appear if the hawkular-services are deployed on a virtual machine managed by RHEV provider and this provider is also added to MiQ.

That's correct.

The cross-linking should just happen automatically.

Depending on the definition of automatically, that's also correct :) @abonas can confirm how it works on the UI, but on this side, all we need to do is to set the lives_on field. Something else will compare these values and show that accordingly on the UI.

If I recall correctly the https://hawkular.torii.gva.redhat.com is running on RHEV and both the hawkular and RHEV can be added as providers to MiQ (juca can give you the access).

Also correct.

Also, do you have any idea how to workaround the ^ for containers? Perhaps we can change the permissions of /etc/machine-id so that it's writable by non-root guys, right? That would work. If you are not against it I am willing to add it back.

I have no idea about that, though, as it probably depends on the outcome of the discussions about the machine ID for containers. In my opinion, /etc/machine-id should not contain the hostname, or anything that doesn't conform with the spec that rules this file: https://www.freedesktop.org/software/systemd/man/machine-id.html

Copy link
Member Author

Choose a reason for hiding this comment

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

@Jiri-Kremser @jpkrohling

If I recall correctly the https://hawkular.torii.gva.redhat.com is running on RHEV

It outputs a "bad gateway" error to me :(

@israel-hdez
Copy link
Member Author

@miq-bot add_label fine/yes, blocker

Please see ManageIQ/manageiq-gems-pending#138 (comment) for backport notes.

@abonas
Copy link
Member

abonas commented Apr 27, 2017

clicking on code climate shows green status, so I'll merge

@israel-hdez
Copy link
Member Author

israel-hdez commented Apr 27, 2017

If this cannot be backported seamlessly to fine, please merge ManageIQ/manageiq#14927.

@simaishi
Copy link

Backported to Fine via ManageIQ/manageiq#14927

@israel-hdez israel-hdez deleted the inventory-on-metrics branch May 4, 2017 18:01
@abonas abonas added this to the Sprint 60 Ending May 8, 2017 milestone May 8, 2017
josejulio added a commit to josejulio/manageiq-providers-hawkular that referenced this pull request Dec 8, 2017
Enable rubocop in CI for pull requests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet