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

Check metrics details from raw_connect #134

Merged
merged 1 commit into from
Nov 8, 2017
Merged

Check metrics details from raw_connect #134

merged 1 commit into from
Nov 8, 2017

Conversation

jhernand
Copy link
Contributor

@jhernand jhernand commented Nov 7, 2017

Currently the raw_connect doesn't check the metrics connection
details. This patch adds that check.

This patch fixes partially the following bug:

RHV provider metrics validation is broken
https://bugzilla.redhat.com/1510533

@jhernand
Copy link
Contributor Author

jhernand commented Nov 7, 2017

@pkliczewski @borod108 @masayag please review.

Take into account that this pull request should be merged after #132. This currently contains two commits, the first is also in that other pull request. So please focus only in the second commit of this pull request.

@jhernand
Copy link
Contributor Author

jhernand commented Nov 7, 2017

Note also that for this to work the UI has to be modified to send the required data. That is pull request ManageIQ/manageiq-ui-classic#2651.

@pkliczewski
Copy link
Contributor

@jhernand This PR requires few changes in vcr files. For now the specs are failing.

@miq-bot
Copy link
Member

miq-bot commented Nov 7, 2017

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

@jhernand
Copy link
Contributor Author

jhernand commented Nov 7, 2017

rescue StandardError => error
raise adapt_metrics_error(error)
ensure
OvirtMetrics.disconnect rescue nil
Copy link
Contributor

Choose a reason for hiding this comment

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

seems that rubocop would prefer

    begin
      OvirtMetrics.disconnect
    rescue
      nil
    end

but we have the same style in line 145

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 will do as Rubocop says.

@oourfali
Copy link
Contributor

oourfali commented Nov 7, 2017

@miq-bot add_label gaprindashvili/yes

# @options opts [String] :metrics_database The name of the metrics database.
# @return [Boolean] Returns `true` if the connection details and credentials are valid, or `false` otherwise.
#
def raw_connect(opts = {})
Copy link
Contributor

Choose a reason for hiding this comment

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

is there anyway we can rename this to something with "validate?"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is the name that the UI uses, it has to be raw_connect.

#
def raw_connect(opts = {})
check_connect_api(opts)
check_connect_metrics(opts)
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we checking both of these? how do we know which one failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to check all the details that the user gives in the UI, if I understand correctly. We won't know what failed, nor do we need: the human user will know, hopefully, using her eyes and brain.

Currently the `raw_connect` doesn't check the metrics connection
details. This patch adds that check.

This patch fixes partially the following bug:

  Failed validation when adding RHV provider
  https://bugzilla.redhat.com/1509432
@miq-bot
Copy link
Member

miq-bot commented Nov 7, 2017

Checked commit https://github.com/jhernand/manageiq-providers-ovirt/commit/1a6e4dc50f1c4644f065ebdc613c277fd1579680 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 🍰

@borod108
Copy link
Contributor

borod108 commented Nov 7, 2017 via email

@jhernand
Copy link
Contributor Author

jhernand commented Nov 7, 2017

@borod108 in my tests the error messages displayed to the user were very informative, and it was easy to determine what was wrong. There is certainly room for improvement, but I really don't want to mix those improvements with fixing the main issue.

@jhernand
Copy link
Contributor Author

jhernand commented Nov 7, 2017

The tests are failing with this error:

     NoMethodError:
       undefined method `manager_ref' for #<ManageIQ::Providers::Redhat::InfraManager::Vm:0x0000000b45efd8>
       Did you mean?  manager_type
     # /home/travis/.rvm/gems/ruby-2.3.1/gems/activemodel-5.0.6/lib/active_model/attribute_methods.rb:433:in `method_missing'
     # ./spec/manageiq/app/models/manager_refresh/target_collection.rb:41:in `collect'
     # ./spec/manageiq/app/models/manager_refresh/target_collection.rb:41:in `id'
     # ./spec/manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:23:in `block (2 levels) in refresh'
     # ./spec/manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:23:in `each'
     # ./spec/manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:23:in `block in refresh'
     # ./spec/manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:14:in `each'
     # ./spec/manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:14:in `refresh'
     # ./spec/manageiq/app/models/manageiq/providers/base_manager/refresher.rb:9:in `refresh'
     # ./spec/manageiq/app/models/ems_refresh.rb:97:in `block in refresh'
     # ./spec/manageiq/app/models/ems_refresh.rb:96:in `each'
     # ./spec/manageiq/app/models/ems_refresh.rb:96:in `refresh'
     # ./spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_target_vm_4_spec.rb:147:in `block (2 levels) in <top (required)>'

I think that isn't related to this change, but rather to ManageIQ/manageiq#16405.

@Ladas @agrare @pkliczewski can you take a look. I think that the reason is that the above pull request assumes that all targeted objects have a manager_ref attribute, but virtual machines don't have it, at least not oVirt virtual machines.

@jhernand
Copy link
Contributor Author

jhernand commented Nov 7, 2017

The fix for the issue that caused the test failure (ManageIQ/manageiq#16411) has been merged. I am closing and re-opening this to re-run the tests.

@jhernand jhernand closed this Nov 7, 2017
@jhernand jhernand reopened this Nov 7, 2017
@masayag masayag merged commit af9c776 into ManageIQ:master Nov 8, 2017
@agrare
Copy link
Member

agrare commented Nov 9, 2017

@simaishi don't backport this until #140 is also merged

simaishi pushed a commit that referenced this pull request Nov 14, 2017
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 0e4e22fea0e8d737ed6a8184137ee0ebf64cd84d
Author: Moti Asayag <masayag@redhat.com>
Date:   Wed Nov 8 09:09:21 2017 +0200

    Merge pull request #134 from jhernand/verify_metrics_details_from_raw_connect
    
    Check metrics details from `raw_connect`
    (cherry picked from commit af9c776d98752f8274d08e21b36163bff555e556)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1511079

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.

8 participants