Skip to content

When hostname in zonefile no longer exist, report a human readable error message

Description of the problem

When ocp-network-split-multisetup is processing a zonefile with host names which can't be translated to IP address, it fails with a traceback without reporting the hostname it failed to process.

Steps to reproduce

  1. Create an invalid zone file:
$ cat testzone.ini
[a]
foo.example.com

[b]
bar.example.com

[c]
baz.example.com
  1. Run ocp network multisetup:
$ ocp-network-split-multisetup --mc test.mc.yaml --env test.env testzone.ini 

Actual results

$ ocp-network-split-multisetup --mc test.mc.yaml --env test.env testzone.ini 
Traceback (most recent call last):
  File "/home/martin/tvorba/ocp-network-split/venv/bin/ocp-network-split-multisetup", line 33, in <module>
    sys.exit(load_entry_point('ocp-network-split', 'console_scripts', 'ocp-network-split-multisetup')())
  File "/home/martin/tvorba/ocp-network-split/ocpnetsplit/main.py", line 426, in main_multisetup
    zone_config = get_zone_config_fromfile(args.zonefile.read())
  File "/home/martin/tvorba/ocp-network-split/ocpnetsplit/main.py", line 122, in get_zone_config_fromfile
    host = socket.gethostbyname(host_name)
socket.gaierror: [Errno -2] Name or service not known

Expected results

ocp-network-split-multisetup reports that there is a problem with name resolution for foo.example.com hostname