Adaptations to have a working refresh for Hawkular's Inventory.next #10
Conversation
CC @abonas |
@israel-hdez thanks for this! is this necessary to rely here on PR #6? |
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.
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) |
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'd call this metrics_for_type
, the second metric
sounds redundant.
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 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 = [] |
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.
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 = [] |
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.
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) |
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.
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.
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. Since hawkular api is web-based, I'll change those CGI
usages with URI
.
@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) |
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.
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. |
@abonas the official |
@israel-hdez yes, it is used also by the containers provider which code currently resides in the main manageiq repo. |
@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. |
I suggest both, |
I expect the gem to be used in:
if one repo bumps a version in a way that is not compatible with another (both cannot be satisfied) |
This pull request is not mergeable. Please rebase and repush. |
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').
3668d3b
to
fdff37b
Compare
@israel-hdez 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.
344a119
to
969f964
Compare
Checked commits israel-hdez/manageiq-providers-hawkular@bed7634~...969f964 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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 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 |
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.
@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.
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.
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.
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.
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
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.
@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 :(
@miq-bot add_label fine/yes, blocker Please see ManageIQ/manageiq-gems-pending#138 (comment) for backport notes. |
clicking on code climate shows green status, so I'll merge |
If this cannot be backported seamlessly to |
Backported to Fine via ManageIQ/manageiq#14927 |
Enable rubocop in CI for pull requests
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