fix reload in empty discovery

This commit is contained in:
Difrex 2016-10-05 11:46:51 +03:00
parent f54a7e0ee8
commit f98677deb9
2 changed files with 32 additions and 8 deletions

View File

@ -68,15 +68,16 @@ while 1:
conf['loglevel'] = 'info'
# Resolve services
app_hosts = resolve(app_conf, conf)
if resolve(app_conf, conf) != 404:
app_hosts = resolve(app_conf, conf)
# Populate my dictionary
my = {"services": app_hosts,
"conf_name": app_conf['conf_name']}
# Populate my dictionary
my = {"services": app_hosts,
"conf_name": app_conf['conf_name']}
# Generate config from template
service_conf = gen(my, app_conf['template'])
# Generate config from template
service_conf = gen(my, app_conf['template'])
first = reload_conf(service_conf, app_conf, first, conf)
first = reload_conf(service_conf, app_conf, first, conf)
sleep(conf['wait_time'])

View File

@ -40,8 +40,30 @@ def resolve(app, conf):
if ports is not None:
for port_name in ports:
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain
# Fast fix of empty query result
# ------------------------------
try:
do_query_test = do_query(fqdn, conf['loglevel'])
if do_query_test['state'] == 404:
return 404
except:
pass
# ------------------------------
hosts[service['name']][port_name] = do_query(fqdn, conf['loglevel'])
else:
# Fast fix of empty query result
# ------------------------------
try:
do_query_test = do_query(fqdn, conf['loglevel'])
if do_query_test['state'] == 404:
return 404
except:
pass
# ------------------------------
fqdn = '_' + service['name'] + '.' + group + '._tcp.' + domain
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
@ -62,6 +84,7 @@ def do_query(fqdn, loglevel):
servers.append(server)
except DNSException:
if loglevel != 'info':
logging.warning("Could not resolve " + fqdn)
logging.error("Could not resolve " + fqdn)
return {"state": 404}
return servers