Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for up to a minute for sync_after_install #33917

Merged
merged 1 commit into from
Jun 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions salt/cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,29 +1279,34 @@ def create(self, vm_, local_master=True):
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 '
Expand Down