mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Do no try to connect to salt master in syndic config test
This commit is contained in:
parent
af9578631e
commit
e8a2cc0488
3 changed files with 10 additions and 5 deletions
|
@ -132,7 +132,7 @@ log = logging.getLogger(__name__)
|
|||
# 6. Handle publications
|
||||
|
||||
|
||||
def resolve_dns(opts, fallback=True):
|
||||
def resolve_dns(opts, connect=True, fallback=True):
|
||||
'''
|
||||
Resolves the master_ip and master_uri options
|
||||
'''
|
||||
|
@ -149,7 +149,7 @@ def resolve_dns(opts, fallback=True):
|
|||
if opts['master'] == '':
|
||||
raise SaltSystemExit
|
||||
ret['master_ip'] = \
|
||||
salt.utils.dns_check(opts['master'], opts['master_port'], True, opts['ipv6'])
|
||||
salt.utils.dns_check(opts['master'], opts['master_port'], connect, True, opts['ipv6'])
|
||||
except SaltClientError:
|
||||
if opts['retry_dns']:
|
||||
while True:
|
||||
|
@ -163,7 +163,7 @@ def resolve_dns(opts, fallback=True):
|
|||
time.sleep(opts['retry_dns'])
|
||||
try:
|
||||
ret['master_ip'] = salt.utils.dns_check(
|
||||
opts['master'], opts['master_port'], True, opts['ipv6']
|
||||
opts['master'], opts['master_port'], connect, True, opts['ipv6']
|
||||
)
|
||||
break
|
||||
except SaltClientError:
|
||||
|
|
|
@ -716,7 +716,7 @@ def ip_bracket(addr):
|
|||
return addr
|
||||
|
||||
|
||||
def dns_check(addr, port, safe=False, ipv6=None):
|
||||
def dns_check(addr, port, connect=True, safe=False, ipv6=None):
|
||||
'''
|
||||
Return the ip resolved by dns, but do not exit on failure, only raise an
|
||||
exception. Obeys system preference for IPv4/6 address resolution.
|
||||
|
@ -739,9 +739,14 @@ def dns_check(addr, port, safe=False, ipv6=None):
|
|||
continue
|
||||
if h[0] == socket.AF_INET6 and ipv6 is False:
|
||||
continue
|
||||
if h[0] == socket.AF_INET6 and connect is False and ipv6 is None:
|
||||
continue
|
||||
|
||||
candidate_addr = ip_bracket(h[4][0])
|
||||
|
||||
if not connect:
|
||||
resolved = candidate_addr
|
||||
|
||||
s = socket.socket(h[0], socket.SOCK_STREAM)
|
||||
try:
|
||||
s.connect((candidate_addr.strip('[]'), port))
|
||||
|
|
|
@ -364,7 +364,7 @@ class ConfigTestCase(TestCase, integration.AdaptedConfigurationTestCaseMixIn):
|
|||
syndic_opts = sconfig.syndic_config(
|
||||
syndic_conf_path, minion_conf_path
|
||||
)
|
||||
syndic_opts.update(salt.minion.resolve_dns(syndic_opts))
|
||||
syndic_opts.update(salt.minion.resolve_dns(syndic_opts, connect=False))
|
||||
root_dir = syndic_opts['root_dir']
|
||||
# id & pki dir are shared & so configured on the minion side
|
||||
self.assertEqual(syndic_opts['id'], 'minion')
|
||||
|
|
Loading…
Add table
Reference in a new issue