Bug 1136015

Summary: Installation of second host failed, if given incorrect FQDN of first host for answer file
Product: [Retired] oVirt Reporter: Artyom <alukiano>
Component: ovirt-hosted-engine-setupAssignee: Sandro Bonazzola <sbonazzo>
Status: CLOSED CURRENTRELEASE QA Contact: meital avital <mavital>
Severity: high Docs Contact:
Priority: medium    
Version: 3.5CC: bugs, ecohen, gklein, iheim, rbalakri, yeylon
Target Milestone: ---Keywords: Patch
Target Release: 3.5.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: integration
Fixed In Version: ovirt-3.5.0_rc2 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-17 12:35:11 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:
Attachments:
Description Flags
setup log none

Description Artyom 2014-09-01 13:01:50 UTC
Created attachment 933363 [details]
setup log

Description of problem:
Installation of second host failed, if given incorrect FQDN of first host for answer file

Version-Release number of selected component (if applicable):
ovirt-hosted-engine-setup-1.2.0-0.1.master.20140820130617.gitd832f86.el6.noarch

How reproducible:
Always

Steps to Reproduce:
1. Have hosted-engine environment with one host
2. Add second host and give incorrect FQDN, when deployment ask to provide host to download answer file
3.

Actual results:
[ ERROR ] Failed to execute stage 'Environment customization': local variable 'transport' referenced before assignment
And deployment failed and not give possibility to re-enter FQDN

Expected results:
Appear error that FQDN not correct but deployment give you possibility to re-enter FQDN or to Abort setup

Additional info:

Comment 1 Artyom 2014-09-01 16:27:19 UTC
In this case we have catch to narrow exception:
try:
                transport = paramiko.Transport((self.environment[
                    ohostedcons.FirstHostEnv.FQDN
                ], 22))
                valid = True
            except paramiko.SSHException as e:
but in transport we have socket.getaddrinfo(hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM) that can drop socket.gaierror in case of not correct hostname, and so we jump forward to 
finally:
    transport.close() and we have 
UnboundLocalError: local variable 'transport' referenced before assignment

So one of solutions it to check if FQDN available before run:
transport = paramiko.Transport((self.environment[
                    ohostedcons.FirstHostEnv.FQDN
                ], 22))

or just add another except (paramiko.SSHException, socket.gaierror) as e:

Comment 2 Sandro Bonazzola 2014-10-17 12:35:11 UTC
oVirt 3.5 has been released and should include the fix for this issue.