Skip to content

Commit

Permalink
Merge pull request #757 from grycap/ctxt_step
Browse files Browse the repository at this point in the history
Fix #756
  • Loading branch information
micafer authored Jan 16, 2019
2 parents 6bd634a + 3ed8080 commit dc3e152
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions IM/ConfManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ def __init__(self, inf, auth, max_ctxt_time=1e9):
self.max_ctxt_time = max_ctxt_time
self._stop_thread = False
self.ansible_process = None
self.failed_step = []
self.logger = logging.getLogger('ConfManager')

def check_running_pids(self, vms_configuring, failed_step):
def check_running_pids(self, vms_configuring):
"""
Update the status of the configuration processes
"""
Expand All @@ -98,7 +97,6 @@ def check_running_pids(self, vms_configuring, failed_step):
if vm.configured:
self.log_info("Configuration process of VM %s success." % vm.im_id)
elif vm.configured is False:
failed_step.append(step)
self.log_info("Configuration process of VM %s failed." % vm.im_id)
else:
self.log_warn("Configuration process of VM %s in unfinished state." % vm.im_id)
Expand All @@ -116,14 +114,13 @@ def check_running_pids(self, vms_configuring, failed_step):
if vm.configured:
self.log_info("Configuration process of master node successfully finished.")
elif vm.configured is False:
failed_step.append(step)
self.log_info("Configuration process of master node failed.")
else:
self.log_warn("Configuration process of master node in unfinished state.")
# Force to save the data to store the log data
IM.InfrastructureList.InfrastructureList.save_data(self.inf.id)

return failed_step, res
return res

def stop(self):
self._stop_thread = True
Expand Down Expand Up @@ -203,7 +200,6 @@ def kill_ctxt_processes(self):
def run(self):
self.log_info("Starting the ConfManager Thread")

self.failed_step = []
last_step = None
vms_configuring = {}

Expand All @@ -225,7 +221,7 @@ def run(self):
vm.configured = False
return

self.failed_step, vms_configuring = self.check_running_pids(vms_configuring, self.failed_step)
vms_configuring = self.check_running_pids(vms_configuring)

# If the queue is empty but there are vms configuring wait and test
# again
Expand All @@ -242,22 +238,19 @@ def run(self):

# if this task is from a next step
if last_step is not None and last_step < step:
if self.failed_step and sorted(self.failed_step)[-1] < step:
self.log_info("Configuration of process of step %s failed, "
"ignoring tasks of step %s." % (sorted(self.failed_step)[-1], step))
vm.configured = False
if vm.is_configured() is False:
self.log_debug("Configuration process of step " + str(last_step) +
" failed, ignoring tasks of later steps.")
else:
# Add the task again to the queue only if the last step was
# OK
# Add the task again to the queue only if the last step was OK
self.inf.add_ctxt_tasks([(step, prio, vm, tasks)])

# If there are any process running of last step, wait
if last_step in vms_configuring and len(vms_configuring[last_step]) > 0:
self.log_info("Waiting processes of step " + str(last_step) + " to finish.")
time.sleep(Config.CONFMAMAGER_CHECK_STATE_INTERVAL)
else:
# if not, update the step, to go ahead with the new
# step
# if not, update the step, to go ahead with the new step
self.log_info("Step " + str(last_step) + " finished. Go to step: " + str(step))
last_step = step
else:
Expand Down

0 comments on commit dc3e152

Please sign in to comment.