Commit bcd8c217 authored by Alain Takoudjou's avatar Alain Takoudjou

grid.promise: add the promise name when raising PromiseError

parent 2f76fd28
...@@ -352,7 +352,7 @@ class PromiseLauncher(object): ...@@ -352,7 +352,7 @@ class PromiseLauncher(object):
Run all promises Run all promises
""" """
promise_list = [] promise_list = []
promise_failed = False failed_promise_name = ""
base_config = { base_config = {
'log-folder': self.log_folder, 'log-folder': self.log_folder,
'partition-folder': self.partition_folder, 'partition-folder': self.partition_folder,
...@@ -399,8 +399,8 @@ class PromiseLauncher(object): ...@@ -399,8 +399,8 @@ class PromiseLauncher(object):
module = reload(module) module = reload(module)
config.update(base_config) config.update(base_config)
if self._launchPromise(name, config, module) and not promise_failed: if self._launchPromise(name, config, module) and not failed_promise_name:
promise_failed = True failed_promise_name = name
if not self.run_only_promise_list and os.path.exists(self.legacy_promise_folder) \ if not self.run_only_promise_list and os.path.exists(self.legacy_promise_folder) \
and os.path.isdir(self.legacy_promise_folder): and os.path.isdir(self.legacy_promise_folder):
...@@ -418,11 +418,11 @@ class PromiseLauncher(object): ...@@ -418,11 +418,11 @@ class PromiseLauncher(object):
} }
config.update(base_config) config.update(base_config)
# We will use promise wrapper to run this # We will use promise wrapper to run this
if self._launchPromise(promise_name, config) and not promise_failed: if self._launchPromise(promise_name, config) and not failed_promise_name:
promise_failed = True failed_promise_name = promise_name
stat_info = os.stat(self.partition_folder) stat_info = os.stat(self.partition_folder)
chownDirectory(self.partition_folder, stat_info.st_uid, stat_info.st_gid) chownDirectory(self.partition_folder, stat_info.st_uid, stat_info.st_gid)
if promise_failed: if failed_promise_name:
raise PromiseError("Promise(s) has failed.") raise PromiseError("Promise %r failed." % failed_promise_name)
...@@ -443,7 +443,7 @@ class RunPromise(GenericPromise): ...@@ -443,7 +443,7 @@ class RunPromise(GenericPromise):
# run promise will fail when promise fail (usefull for slapgrid) # run promise will fail when promise fail (usefull for slapgrid)
with self.assertRaises(PromiseError) as exc: with self.assertRaises(PromiseError) as exc:
self.launcher.run() self.launcher.run()
self.assertEquals(exc.exception.message, 'Promise(s) has failed.') self.assertEquals(exc.exception.message, 'Promise %r failed.' % second_promise)
if "my_second_promise" in sys.modules: if "my_second_promise" in sys.modules:
# force to reload the module without rerun python # force to reload the module without rerun python
...@@ -618,7 +618,7 @@ exit 1 ...@@ -618,7 +618,7 @@ exit 1
state_file = os.path.join(self.partition_dir, PROMISE_STATE_FOLDER_NAME) state_file = os.path.join(self.partition_dir, PROMISE_STATE_FOLDER_NAME)
with self.assertRaises(PromiseError) as exc: with self.assertRaises(PromiseError) as exc:
self.launcher.run() self.launcher.run()
self.assertEquals(exc.exception.message, 'Promise(s) has failed.') self.assertEquals(exc.exception.message, 'Promise %r failed.' % promise_name)
def test_runpromise_wrapped_mixed(self): def test_runpromise_wrapped_mixed(self):
self.called = 0 self.called = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment