mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Wait for up to a minute for sync_after_install (#33917)
This commit is contained in:
parent
ef6da0be5d
commit
91a2184f2d
1 changed files with 23 additions and 18 deletions
|
@ -1279,29 +1279,34 @@ class Cloud(object):
|
|||
log.error('Bad option for sync_after_install')
|
||||
return output
|
||||
|
||||
# a small pause makes the sync work reliably
|
||||
# A small pause helps the sync work more reliably
|
||||
time.sleep(3)
|
||||
|
||||
mopts_ = salt.config.DEFAULT_MINION_OPTS
|
||||
conf_path = '/'.join(self.opts['conf_file'].split('/')[:-1])
|
||||
mopts_.update(
|
||||
salt.config.minion_config(
|
||||
os.path.join(conf_path,
|
||||
'minion')
|
||||
start = int(time.time())
|
||||
while int(time.time()) < start + 60:
|
||||
# We'll try every <timeout> seconds, up to a minute
|
||||
mopts_ = salt.config.DEFAULT_MINION_OPTS
|
||||
conf_path = '/'.join(self.opts['conf_file'].split('/')[:-1])
|
||||
mopts_.update(
|
||||
salt.config.minion_config(
|
||||
os.path.join(conf_path,
|
||||
'minion')
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
client = salt.client.get_local_client(mopts=self.opts)
|
||||
client = salt.client.get_local_client(mopts=self.opts)
|
||||
|
||||
ret = client.cmd(
|
||||
vm_['name'],
|
||||
'saltutil.sync_{0}'.format(self.opts['sync_after_install']),
|
||||
timeout=self.opts['timeout']
|
||||
)
|
||||
log.info(
|
||||
six.u('Synchronized the following dynamic modules: '
|
||||
' {0}').format(ret)
|
||||
)
|
||||
ret = client.cmd(
|
||||
vm_['name'],
|
||||
'saltutil.sync_{0}'.format(self.opts['sync_after_install']),
|
||||
timeout=self.opts['timeout']
|
||||
)
|
||||
if ret:
|
||||
log.info(
|
||||
six.u('Synchronized the following dynamic modules: '
|
||||
' {0}').format(ret)
|
||||
)
|
||||
break
|
||||
except KeyError as exc:
|
||||
log.exception(
|
||||
six.u('Failed to create VM {0}. Configuration value {1} needs '
|
||||
|
|
Loading…
Add table
Reference in a new issue