Wait for up to a minute for sync_after_install (#33917)

This commit is contained in:
Joseph Hall 2016-06-10 09:14:59 -06:00 committed by Nicole Thomas
parent ef6da0be5d
commit 91a2184f2d

View file

@ -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 '