[BETA] bug: error info lost with parallel (option -j) #632
This commit is contained in:
parent
44673131fc
commit
cf36aece7d
2 changed files with 74 additions and 66 deletions
110
cdist/config.py
110
cdist/config.py
|
@ -486,30 +486,27 @@ class Config(object):
|
||||||
objects_changed = False
|
objects_changed = False
|
||||||
|
|
||||||
for cdist_object in self.object_list():
|
for cdist_object in self.object_list():
|
||||||
try:
|
if cdist_object.requirements_unfinished(
|
||||||
if cdist_object.requirements_unfinished(
|
cdist_object.requirements):
|
||||||
cdist_object.requirements):
|
"""We cannot do anything for this poor object"""
|
||||||
"""We cannot do anything for this poor object"""
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
if cdist_object.state == core.CdistObject.STATE_UNDEF:
|
if cdist_object.state == core.CdistObject.STATE_UNDEF:
|
||||||
"""Prepare the virgin object"""
|
"""Prepare the virgin object"""
|
||||||
|
|
||||||
self.object_prepare(cdist_object)
|
self.object_prepare(cdist_object)
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
|
|
||||||
if cdist_object.requirements_unfinished(
|
if cdist_object.requirements_unfinished(
|
||||||
cdist_object.autorequire):
|
cdist_object.autorequire):
|
||||||
"""The previous step created objects we depend on -
|
"""The previous step created objects we depend on -
|
||||||
wait for them
|
wait for them
|
||||||
"""
|
"""
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
if cdist_object.state == core.CdistObject.STATE_PREPARED:
|
||||||
self.object_run(cdist_object)
|
self.object_run(cdist_object)
|
||||||
objects_changed = True
|
objects_changed = True
|
||||||
except cdist.Error as e:
|
|
||||||
raise cdist.CdistObjectError(cdist_object, e)
|
|
||||||
|
|
||||||
return objects_changed
|
return objects_changed
|
||||||
|
|
||||||
|
@ -694,42 +691,49 @@ class Config(object):
|
||||||
|
|
||||||
def object_prepare(self, cdist_object, transfer_type_explorers=True):
|
def object_prepare(self, cdist_object, transfer_type_explorers=True):
|
||||||
"""Prepare object: Run type explorer + manifest"""
|
"""Prepare object: Run type explorer + manifest"""
|
||||||
self.log.verbose("Preparing object {}".format(cdist_object.name))
|
try:
|
||||||
self.log.verbose(
|
self.log.verbose("Preparing object {}".format(cdist_object.name))
|
||||||
"Running manifest and explorers for " + cdist_object.name)
|
self.log.verbose(
|
||||||
self.explorer.run_type_explorers(cdist_object, transfer_type_explorers)
|
"Running manifest and explorers for " + cdist_object.name)
|
||||||
self.manifest.run_type_manifest(cdist_object)
|
self.explorer.run_type_explorers(cdist_object,
|
||||||
cdist_object.state = core.CdistObject.STATE_PREPARED
|
transfer_type_explorers)
|
||||||
|
self.manifest.run_type_manifest(cdist_object)
|
||||||
|
cdist_object.state = core.CdistObject.STATE_PREPARED
|
||||||
|
except cdist.Error as e:
|
||||||
|
raise cdist.CdistObjectError(cdist_object, e)
|
||||||
|
|
||||||
def object_run(self, cdist_object):
|
def object_run(self, cdist_object):
|
||||||
"""Run gencode and code for an object"""
|
"""Run gencode and code for an object"""
|
||||||
|
try:
|
||||||
|
self.log.verbose("Running object " + cdist_object.name)
|
||||||
|
if cdist_object.state == core.CdistObject.STATE_DONE:
|
||||||
|
raise cdist.Error(("Attempting to run an already finished "
|
||||||
|
"object: %s"), cdist_object)
|
||||||
|
|
||||||
self.log.verbose("Running object " + cdist_object.name)
|
# Generate
|
||||||
if cdist_object.state == core.CdistObject.STATE_DONE:
|
self.log.debug("Generating code for %s" % (cdist_object.name))
|
||||||
raise cdist.Error(("Attempting to run an already finished "
|
cdist_object.code_local = self.code.run_gencode_local(cdist_object)
|
||||||
"object: %s"), cdist_object)
|
cdist_object.code_remote = self.code.run_gencode_remote(
|
||||||
|
cdist_object)
|
||||||
|
if cdist_object.code_local or cdist_object.code_remote:
|
||||||
|
cdist_object.changed = True
|
||||||
|
|
||||||
# Generate
|
# Execute
|
||||||
self.log.debug("Generating code for %s" % (cdist_object.name))
|
if cdist_object.code_local or cdist_object.code_remote:
|
||||||
cdist_object.code_local = self.code.run_gencode_local(cdist_object)
|
self.log.info("Processing %s" % (cdist_object.name))
|
||||||
cdist_object.code_remote = self.code.run_gencode_remote(cdist_object)
|
if not self.dry_run:
|
||||||
if cdist_object.code_local or cdist_object.code_remote:
|
if cdist_object.code_local:
|
||||||
cdist_object.changed = True
|
self.log.trace("Executing local code for %s"
|
||||||
|
% (cdist_object.name))
|
||||||
|
self.code.run_code_local(cdist_object)
|
||||||
|
if cdist_object.code_remote:
|
||||||
|
self.log.trace("Executing remote code for %s"
|
||||||
|
% (cdist_object.name))
|
||||||
|
self.code.transfer_code_remote(cdist_object)
|
||||||
|
self.code.run_code_remote(cdist_object)
|
||||||
|
|
||||||
# Execute
|
# Mark this object as done
|
||||||
if cdist_object.code_local or cdist_object.code_remote:
|
self.log.trace("Finishing run of " + cdist_object.name)
|
||||||
self.log.info("Processing %s" % (cdist_object.name))
|
cdist_object.state = core.CdistObject.STATE_DONE
|
||||||
if not self.dry_run:
|
except cdist.Error as e:
|
||||||
if cdist_object.code_local:
|
raise cdist.CdistObjectError(cdist_object, e)
|
||||||
self.log.trace("Executing local code for %s"
|
|
||||||
% (cdist_object.name))
|
|
||||||
self.code.run_code_local(cdist_object)
|
|
||||||
if cdist_object.code_remote:
|
|
||||||
self.log.trace("Executing remote code for %s"
|
|
||||||
% (cdist_object.name))
|
|
||||||
self.code.transfer_code_remote(cdist_object)
|
|
||||||
self.code.run_code_remote(cdist_object)
|
|
||||||
|
|
||||||
# Mark this object as done
|
|
||||||
self.log.trace("Finishing run of " + cdist_object.name)
|
|
||||||
cdist_object.state = core.CdistObject.STATE_DONE
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import cdist
|
||||||
from cdist.mputil import mp_pool_run
|
from cdist.mputil import mp_pool_run
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
|
@ -213,19 +214,22 @@ class Explorer(object):
|
||||||
def transfer_type_explorers(self, cdist_type):
|
def transfer_type_explorers(self, cdist_type):
|
||||||
"""Transfer the type explorers for the given type to the
|
"""Transfer the type explorers for the given type to the
|
||||||
remote side."""
|
remote side."""
|
||||||
if cdist_type.explorers:
|
try:
|
||||||
if cdist_type.name in self._type_explorers_transferred:
|
if cdist_type.explorers:
|
||||||
self.log.trace("Skipping retransfer of type explorers for: %s",
|
if cdist_type.name in self._type_explorers_transferred:
|
||||||
cdist_type)
|
self.log.trace(("Skipping retransfer of type explorers "
|
||||||
else:
|
"for: %s"), cdist_type)
|
||||||
source = os.path.join(self.local.type_path,
|
else:
|
||||||
cdist_type.explorer_path)
|
source = os.path.join(self.local.type_path,
|
||||||
destination = os.path.join(self.remote.type_path,
|
cdist_type.explorer_path)
|
||||||
cdist_type.explorer_path)
|
destination = os.path.join(self.remote.type_path,
|
||||||
self.remote.mkdir(destination)
|
cdist_type.explorer_path)
|
||||||
self.remote.transfer(source, destination)
|
self.remote.mkdir(destination)
|
||||||
self.remote.run(["chmod", "0700", "%s/*" % (destination)])
|
self.remote.transfer(source, destination)
|
||||||
self._type_explorers_transferred.append(cdist_type.name)
|
self.remote.run(["chmod", "0700", "%s/*" % (destination)])
|
||||||
|
self._type_explorers_transferred.append(cdist_type.name)
|
||||||
|
except cdist.Error as e:
|
||||||
|
raise cdist.CdistObjectError(cdist_object, e)
|
||||||
|
|
||||||
def transfer_object_parameters(self, cdist_object):
|
def transfer_object_parameters(self, cdist_object):
|
||||||
"""Transfer the parameters for the given object to the remote side."""
|
"""Transfer the parameters for the given object to the remote side."""
|
||||||
|
|
Loading…
Reference in a new issue