fix reload in empty discovery
This commit is contained in:
parent
f54a7e0ee8
commit
f98677deb9
1
surok.py
1
surok.py
@ -68,6 +68,7 @@ while 1:
|
|||||||
conf['loglevel'] = 'info'
|
conf['loglevel'] = 'info'
|
||||||
|
|
||||||
# Resolve services
|
# Resolve services
|
||||||
|
if resolve(app_conf, conf) != 404:
|
||||||
app_hosts = resolve(app_conf, conf)
|
app_hosts = resolve(app_conf, conf)
|
||||||
|
|
||||||
# Populate my dictionary
|
# Populate my dictionary
|
||||||
|
@ -40,8 +40,30 @@ def resolve(app, conf):
|
|||||||
if ports is not None:
|
if ports is not None:
|
||||||
for port_name in ports:
|
for port_name in ports:
|
||||||
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain
|
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'])
|
hosts[service['name']][port_name] = do_query(fqdn, conf['loglevel'])
|
||||||
else:
|
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
|
fqdn = '_' + service['name'] + '.' + group + '._tcp.' + domain
|
||||||
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
|
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
|
||||||
|
|
||||||
@ -62,6 +84,7 @@ def do_query(fqdn, loglevel):
|
|||||||
servers.append(server)
|
servers.append(server)
|
||||||
except DNSException:
|
except DNSException:
|
||||||
if loglevel != 'info':
|
if loglevel != 'info':
|
||||||
logging.warning("Could not resolve " + fqdn)
|
logging.error("Could not resolve " + fqdn)
|
||||||
|
return {"state": 404}
|
||||||
|
|
||||||
return servers
|
return servers
|
||||||
|
Loading…
Reference in New Issue
Block a user