Skip to content

Commit

Permalink
Merge pull request #679 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Oct 1, 2018
2 parents cf43d8c + 9beed32 commit 4ac8d19
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ def call_ansible(self, tmp_dir, inventory, playbook, ssh):
self.ansible_process.start()

wait = 0
while self.ansible_process.is_alive():
while result.empty() and self.ansible_process.is_alive():
if wait >= Config.ANSIBLE_INSTALL_TIMEOUT:
self.log_error('Timeout waiting Ansible process to finish')
try:
Expand All @@ -1233,7 +1233,7 @@ def call_ansible(self, tmp_dir, inventory, playbook, ssh):

try:
self.log_info('Get the results of the Ansible process.')
_, (return_code, _), output = result.get(timeout=10)
_, (return_code, _), output = result.get(timeout=10, block=False)
msg = output.getvalue()
self.log_info('Results obtained')
except:
Expand Down
9 changes: 9 additions & 0 deletions IM/ansible_utils/ansible_executor_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import logging
import sys
import tempfile
import shutil

from ansible import constants as C
from ansible.plugins.callback import CallbackBase
Expand Down Expand Up @@ -363,6 +365,9 @@ def run(self):
Run the given playbook, based on the settings in the play which
may limit the runs to serialized groups, etc.
'''
# Create a specific dir for the local temp
C.DEFAULT_LOCAL_TMP = tempfile.mkdtemp()

result = 0
try:
for playbook_path in self._playbooks:
Expand Down Expand Up @@ -451,4 +456,8 @@ def run(self):
if self._tqm is not None:
self._tqm.cleanup()

try:
shutil.rmtree(C.DEFAULT_LOCAL_TMP, True)
except:
pass
return result
6 changes: 5 additions & 1 deletion IM/ansible_utils/ansible_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def teminate(self):

def _get_childs(self, parent_id=None):
if parent_id is None:
parent_id = os.getpid()
parent_id = self.pid
if parent_id is None:
return []
ps_command = subprocess.Popen("ps -o pid --ppid %d --noheaders" % parent_id, shell=True, stdout=subprocess.PIPE)
ps_command.wait()
ps_output = str(ps_command.stdout.read())
Expand Down Expand Up @@ -132,6 +134,8 @@ def run(self):
except errors.AnsibleError as e:
display("ERROR: %s" % e, output=self.output)
self.result.put((0, (1, []), output))
finally:
self._kill_childs()

def get_play_prereqs(self, options):
if LooseVersion(ansible_version) >= LooseVersion("2.4.0"):
Expand Down
2 changes: 1 addition & 1 deletion contextualization/conf-ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
gather_facts: false
vars:
# Ansible specific Version or "latest"
ANSIBLE_VERSION: 2.4.6
ANSIBLE_VERSION: 2.5.9
tasks:
# Some OSs does not have python by default
- name: Check Python is installed
Expand Down
2 changes: 1 addition & 1 deletion contextualization/ctxt_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def wait_thread(thread_data, output=None):
thread, result = thread_data
thread.join()
try:
_, (return_code, hosts_with_errors), _ = result.get(timeout=60)
_, (return_code, hosts_with_errors), _ = result.get(timeout=60, block=False)
except:
CtxtAgent.logger.exception('Error getting ansible results.')
return_code = -1
Expand Down
2 changes: 1 addition & 1 deletion contextualization/ctxt_agent_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def wait_thread(thread_data, general_conf_data, copy, output=None, poll_delay=1,
CtxtAgent.logger.exception("Error putting %s file" % (vm_dir + "/ctxt_agent.log"))

try:
_, (return_code, hosts_with_errors), _ = result.get(timeout=60)
_, (return_code, hosts_with_errors), _ = result.get(timeout=60, block=False)
except:
CtxtAgent.logger.exception('Error getting ansible results.')
return_code = -1
Expand Down
2 changes: 1 addition & 1 deletion etc/im.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ UPDATE_CTXT_LOG_INTERVAL = 20
# Interval to update the state of the processes of the ConfManager (in secs)
CONFMAMAGER_CHECK_STATE_INTERVAL = 5
# Max time expected to install Ansible in the master node
ANSIBLE_INSTALL_TIMEOUT = 1800
ANSIBLE_INSTALL_TIMEOUT = 500
# Number of VMs in an infrastructure that will use the distributed version of the Ctxt Agent
VM_NUM_USE_CTXT_DIST = 30

Expand Down

0 comments on commit 4ac8d19

Please sign in to comment.