Bug 1334162

Summary: nova-compute-wait complains about Invalid Nova host name.
Product: Red Hat Enterprise Linux 7 Reporter: Andrew Beekhof <abeekhof>
Component: fence-agentsAssignee: Oyvind Albrigtsen <oalbrigt>
Status: CLOSED ERRATA QA Contact: Asaf Hirshberg <ahirshbe>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: abeekhof, agk, cluster-maint, fdinitto, mkrcmari, oalbrigt, oblaut, ushkalim
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: fence-agents-4.0.11-40.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1320783 Environment:
Last Closed: 2016-11-04 04:50:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1320783    
Bug Blocks:    

Comment 4 Oyvind Albrigtsen 2016-07-04 13:52:33 UTC
New build to fix 'nil' issue (see https://bugzilla.redhat.com/show_bug.cgi?id=1287311 for more info).

Comment 5 Asaf Hirshberg 2016-07-18 06:27:49 UTC
Andrew,
Can you please share reproducing steps?

Comment 6 Andrew Beekhof 2016-07-19 03:54:14 UTC
Pulling info from the description:

1. specify host as FQDN in nova.conf (eg. overcloud-controller-0.localdomain)
2. specify hostname of the node in pcs as FQDN (eg. overcloud-controller-0.localdomain)
3. set domain attribute of the remote resource (eg. localdomain)

Old agent: complains about invalid nova host name
New agent: works

Comment 7 Asaf Hirshberg 2016-08-07 06:37:21 UTC
Code Verified, 
[root@overcloud-controller-0 heat-admin]# rpm -qa |grep fence-agents-com
fence-agents-common-4.0.11-40.el7.x86_64
fence-agents-compute-4.0.11-40.el7.x86_64

[root@overcloud-controller-0 heat-admin]# sed -n '205,284p' /usr/sbin/fence_compute 
			logging.debug("Waiting for nova to update it's internal state for %s" % options["--plug"])
			time.sleep(1)

	if not _host_evacuate(options):
		sys.exit(1)

	return


def fix_domain(options):
	domains = {}
	last_domain = None

	if nova:
		# Find it in nova

		hypervisors = nova.hypervisors.list()
		for hypervisor in hypervisors:
			shorthost = hypervisor.hypervisor_hostname.split('.')[0]

			if shorthost == hypervisor.hypervisor_hostname:
				# Nova is not using FQDN 
				calculated = ""
			else:
				# Compute nodes are named as FQDN, strip off the hostname
				calculated = hypervisor.hypervisor_hostname.replace(shorthost+".", "")

			domains[calculated] = shorthost

			if calculated == last_domain:
				# Avoid complaining for each compute node with the same name
				# One hopes they don't appear interleaved as A.com B.com A.com B.com
				logging.debug("Calculated the same domain from: %s" % hypervisor.hypervisor_hostname)

			elif options.has_key("--domain") and options["--domain"] == calculated:
				# Supplied domain name is valid 
				return

			elif options.has_key("--domain"):
				# Warn in case nova isn't available at some point
				logging.warning("Supplied domain '%s' does not match the one calculated from: %s"
					      % (options["--domain"], hypervisor.hypervisor_hostname))

			last_domain = calculated

	if len(domains) == 0 and not options.has_key("--domain"):
		logging.error("Could not calculate the domain names used by compute nodes in nova")

	elif len(domains) == 1 and not options.has_key("--domain"):
		options["--domain"] = last_domain

	elif len(domains) == 1:
		logging.error("Overriding supplied domain '%s' does not match the one calculated from: %s"
			      % (options["--domain"], hypervisor.hypervisor_hostname))
		options["--domain"] = last_domain

	elif len(domains) > 1:
		logging.error("The supplied domain '%s' did not match any used inside nova: %s"
			      % (options["--domain"], repr(domains)))
		sys.exit(1)

def fix_plug_name(options):
	if options["--action"] == "list":
		return

	if not options.has_key("--plug"):
		return

	fix_domain(options)
	short_plug = options["--plug"].split('.')[0]
	logging.debug("Checking target '%s' against calculated domain '%s'"% (options["--plug"], calculated))

	if not options.has_key("--domain"):
		# Nothing supplied and nova not available... what to do... nothing
		return

	elif options["--domain"] == "":
		# Ensure any domain is stripped off since nova isn't using FQDN
		options["--plug"] = short_plug

[root@overcloud-controller-0 heat-admin]#

Comment 9 errata-xmlrpc 2016-11-04 04:50:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2373.html