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

Resolve oVirt IP addresses #13767

Merged
merged 1 commit into from
Feb 14, 2017
Merged

Resolve oVirt IP addresses #13767

merged 1 commit into from
Feb 14, 2017

Conversation

jhernand
Copy link
Contributor

@jhernand jhernand commented Feb 6, 2017

Since version 4 oVirt rejects connections that use directly the IP address instead of the host name. This is a side effect of the new SSO authentication mechanism. That means that when a oVirt provider is added using an IP address it will not work. Users don't do this frequently, but the system does it automatically when the provider is added using the discovery mechanism, as this mechanism uses IP addresses only. To avoid this issue this patch changes the provider so that when it receives an IP address it tries to convert it to the corresponding fully qualified host name.

There may be situations where the user really wants to use an IP address, and not the host name. For those cases this patch also introduces a new resolve_ip_addresses setting that can be used to disable resolving. This setting will be stored in the config/settings.yml file, and its default value will be true:

:ems:
  :ems_redhat:
    :resolve_ip_addresses: true

https://bugzilla.redhat.com/1417757

@jhernand
Copy link
Contributor Author

jhernand commented Feb 6, 2017

@masayag @borod108 @durandom please review.

@jhernand
Copy link
Contributor Author

jhernand commented Feb 6, 2017

Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

Overall nice documented PR.

2 minor issues - see comments.

Also, I think we should involve docs here, because it's not obvious whats going on and we introduce a new setting.

@oourfali do you know how to trigger docs?

# @return [String] The host name.
#
def resolve_ip_address(address)
require 'resolv'
Copy link
Member

Choose a reason for hiding this comment

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

I dont think you need this because you are using stdlib stuff - but then I see it other places too.
@chrisarcand is there a reason to require here? like we do `require 'ostruct' here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about the rails environment, but in plain Ruby this fails without the require, even if resolv is part of the stdlib.

Copy link
Member

Choose a reason for hiding this comment

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

  • You do need a require under normal circumstances as while it's part of stdlib, it isn't loaded by default.
  • The module is present in our current Rails env, it's not clear as to what actually adds it, probably Rails for it's own purposes. So...
  • It's appropriate to require it in this file as it's a required dependency, but I'd put it at the top of the file instead of within the method itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I will put it at the top of the file.

Note that in other cases I have seen the opposite comment: put the requires only where they are needed, not at the top of file. Is there a rationale or common rule about where should requires go?

Copy link
Member

Choose a reason for hiding this comment

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

If there is a hard-and-fast rule, usually it's what we described here: put at the top of the file.

There are specific exceptions, though; For example, in the ovirt_metrics gem I needed to write a custom adapter for dealing with an old version of Postgres on Ovirt databases that isn't supported by Rails 5 (what we run). As the adapter isn't required for Rails < 5, I require it inline based on which version of Rails you're running. I don't want the adapter required when it isn't necessary (it's very large and expensive to load)

Here it looks like you're adding some core functionality that should always run, so we'll consider it a true dependency that we'll specify at the beginning of the file.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thanks for the explanation @chrisarcand , I will move the require to the top of the file in the next version of the pull request.

@@ -97,6 +97,7 @@
:purge_window_size: 10000
:ems:
:ems_redhat:
:resolve_ip_addresses: true
Copy link
Member

Choose a reason for hiding this comment

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

I think this setting is not really self explanatory. But I dont know how could be really short and good.

resolve_ip_address_for_ovirt_manager_connect: true ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can this be commented? I didn't see comments in this file, but if possible, I'd like to write a comment explaining the meaning. Something like this:

#
# Indicates if the oVirt provider should try to convert IP addresses
# to host names, using a reverse DNS lookup if required. This is
# needed because since version 4 of oVirt connections that use
# an IP address directly are rejected. Change to 'false' only if you
# have explicitly configured the oVirt engine to use IP addresses
# and you don't have a working DNS configuration.
#
:resolve_ip_addresses: true

Assuming comments are allowed, would that be enough?

Copy link
Member

Choose a reason for hiding this comment

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

It's possible, but they dont show up in the UI :(

Thats why I think we should a) do a corresponding doc update. I guess the docs request in the BZ is enough. Though it would be nice to involve the docs team right here on the PR.
@adahms ?

Copy link
Member

Choose a reason for hiding this comment

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

@oourfali what do you think about the naming of this config option?

Copy link

Choose a reason for hiding this comment

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

@durandom - Thank you for adding me to the discussion. If the change is visible in the UI, which it looks like it will be, then we can add a step and a note to the procedure on adding RHV providers to call out this behaviour.

Would that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adahms what is the process to add that text to the providers guide? Sending a pull request to some GitHub repository? Where? Will you take care of it or should I?

Copy link

Choose a reason for hiding this comment

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

@jhernand I have now raised the following bug to address this request, and the content will be added in the upstream and sync'ed with the downstream -

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Graeat, thanks @adahms. @durandom anything else before merging this pull request?

Copy link
Member

Choose a reason for hiding this comment

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

@jhernand @adahms thanks for working this out and making sure it gets proper attention from docs.
I think its good to go now 👍

Copy link

Choose a reason for hiding this comment

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

@jhernand - Nothing else from documentation. Thank you for calling out this change!

@jhernand
Copy link
Contributor Author

jhernand commented Feb 7, 2017

@durandom I requested a release note in the bug. Please review it and tell me if something else is needed in order to trigger docs.

@jhernand
Copy link
Contributor Author

jhernand commented Feb 7, 2017

The only change in the new version of the pull request is moving the require 'resolv' to the top of the file.

@durandom
Copy link
Member

durandom commented Feb 7, 2017

cool, thanks @jhernand - now waiting for @oourfali thoughts on the config setting name and the docs.

@durandom
Copy link
Member

@jhernand could you re-base on current master, amend the last commit or close/open the PR to trigger the CI?

Since version 4 oVirt rejects connections that use directly the IP
address instead of the host name. This is a side effect of the new SSO
authentication mechanism. That means that when a oVirt provider is added
using an IP address it will not work. Users don't do this frequently,
but the system does it automatically when the provider is added using
the discovery mechanism, as this mechanism uses IP addresses only. To
avoid this issue this patch changes the provider so that when it
receives an IP address it tries to convert it to the corresponding fully
qualified host name.

There may be situations where the user really wants to use an IP
address, and not the host name. For those cases this patch also
introduces a new 'resolve_ip_addresses' setting that can be used to
disable resolving. This setting will be stored in the
'config/settings.yml' file, and its default value will be 'true':

  :ems:
    :ems_redhat:
      :resolve_ip_addresses: true

https://bugzilla.redhat.com/1417757
@jhernand
Copy link
Contributor Author

Rebased, no changes.

@miq-bot
Copy link
Member

miq-bot commented Feb 13, 2017

Checked commit https://github.com/jhernand/manageiq/commit/8df5bb0ce29b51928ecee75978e30ea80603e582 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks good. 👍

@blomquisg blomquisg merged commit bf9967a into ManageIQ:master Feb 14, 2017
@blomquisg blomquisg added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 14, 2017
@jhernand jhernand deleted the resolve_ovirt_ip_addresses branch February 14, 2017 14:27
@jhernand
Copy link
Contributor Author

@miq-bot add_label euwe/yes

@simaishi
Copy link
Contributor

simaishi commented Mar 3, 2017

@jhernand This isn't a clean cherry-pick due to some refactoring done on master branch. Can you make an Euwe-specific PR (referencing this one) or suggest other PRs to backport.

@jhernand
Copy link
Contributor Author

jhernand commented Mar 4, 2017

@simaishi Yes, I'll prepare an Euwe-specific PR.

@jhernand
Copy link
Contributor Author

jhernand commented Mar 4, 2017

@simaishi Here is the back-port for Euwe: #14183. Please don't merge it yet. I will verify that it works correctly in the Euwe branch and then I will let you know.

simaishi added a commit that referenced this pull request Mar 14, 2017
[EUWE] Resolve oVirt IP addresses (backport of #13767)
@simaishi
Copy link
Contributor

Backported to Euwe via #14183

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