-
Notifications
You must be signed in to change notification settings - Fork 92
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
Use only hypervisor hostname to match infra host with cloud vm #186
Use only hypervisor hostname to match infra host with cloud vm #186
Conversation
The fix looks reasonable to me 👍 Waiting till tests - IP/hostname issue is fixed. |
@@ -286,7 +286,7 @@ def vms | |||
|
|||
collector.vms.each do |s| | |||
if hosts && !s.os_ext_srv_attr_host.blank? | |||
parent_host = hosts.find_by('lower(hypervisor_hostname) = ?', s.os_ext_srv_attr_host.downcase) | |||
parent_host = hosts.find_by('lower(hypervisor_hostname) = ?', s.os_ext_srv_attr_host.split('.').first.downcase) |
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.
Maybe split(/\.[^0-9]/)
? (and IPv6 doesn't have dots)..
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.
Can you use os_ext_srv_attr_hypervisor_hostname
? Is that field available on the OSP server model from the API?
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.
os_ext_srv_attr_hypervisor_hostname
should be available in OSP running on top of libvirt/kvm. I am not sure we should generally suppose that this field is available when running OS on other hypervisor (as answer you linked states).
Docs https://developer.openstack.org/api-ref/compute/#show-server-details says that host
is The name of the compute host on which this instance is running.
and hypervisor_hostname
is The hypervisor host name provided by the Nova virt driver. For the Ironic driver, it is the Ironic node uuid.
That seems like it should be populated by other hypervisors than libvirt/kvm. Anyway in TripleO installed OSP using libvirt/kvm both os_ext_srv_attr_hypervisor_hostname
and os_ext_srv_attr_host
have the same value.
Hosts in ManageIQ got their hypervisor_hostname
attribute from name
of server in Nova from Undercloud (
manageiq-providers-openstack/app/models/manageiq/providers/openstack/infra_manager/refresh_parser.rb
Line 331 in fe9a981
indexed_servers.fetch_path(host.instance_uuid).try(:name) |
name
is defined by TripleO Heat Templates used to deploy OSP.
So in the end we trust that TripleO (THT) sets the hostnames for compute nodes to the same value (almost - hostname vs fqdn) as their names in Undercloud Nova.
The test that's failing seems to have nothing to do with the changes here, but something in the OpenStack Refresher is broken, so maybe related??
Additionally, I think you should add a test for this change. The trick is since the host is probably coming from a different provider (undercloud), you might not be able to do this in the basic refresh test. Maybe mock an undercloud provider with a host that matches one of the VMs in the VCR cassette? |
@blomquisg in fact it is connected - in tests we have IP addresses instead hostnames and fqdns so my change with I will enhance that matching code to probably match both |
Hosts are stored in db with only hostname part of hostname.domain which we can see in OpenStack. That caused issue with matching VMs with Hosts when Cloud OpenStack had Infra OpenStack related to it. Solves https://bugzilla.redhat.com/show_bug.cgi?id=1528162
Checked commit https://github.com/petrblaho/manageiq-providers-openstack/commit/e579e0d933103028f587c1b620d794979088de4e with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
I updated code with new 'compound' matching for both splitted and full string. |
Looks good to me, merging! Agree on test should be added later. |
…heck-in-inventory-parser-cloud-manager-bz1528162 Use only hypervisor hostname to match infra host with cloud vm (cherry picked from commit a662f25) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1532347
Gaprindashvili backport details:
|
Hosts are stored in db with only hostname part of hostname.domain which
we can see in OpenStack.
That caused issue with matching VMs with Hosts when Cloud OpenStack had
Infra OpenStack related to it.
Solves https://bugzilla.redhat.com/show_bug.cgi?id=1528162