def _fail_workflow(self, final_context, msg): if states.is_paused_or_completed(self.wf_ex.state): return output_on_error = {} try: output_on_error = data_flow.evaluate_workflow_output( self.wf_ex, self.wf_spec.get_output_on_error(), final_context) except exc.MistralException as e: msg = ("Failed to evaluate expression in output-on-error! " "(output-on-error: '%s', exception: '%s' Cause: '%s'" % (self.wf_spec.get_output_on_error(), e, msg)) LOG.error(msg) self.set_state(states.ERROR, state_info=msg) # When we set an ERROR state we should safely set output value getting # w/o exceptions due to field size limitations. length_output_on_error = len(str(output_on_error).encode("utf-8")) total_output_length = utils.get_number_of_chars_from_kilobytes( cfg.CONF.engine.execution_field_size_limit_kb) if length_output_on_error < total_output_length: msg = utils.cut_by_char( msg, total_output_length - length_output_on_error) else: msg = utils.cut_by_kb( msg, cfg.CONF.engine.execution_field_size_limit_kb) self.wf_ex.output = merge_dicts({'result': msg}, output_on_error) if self.wf_ex.task_execution_id: self._send_result_to_parent_workflow()
def _fail_workflow(self, final_context, msg): if states.is_paused_or_completed(self.wf_ex.state): return output_on_error = {} try: output_on_error = data_flow.evaluate_workflow_output( self.wf_ex, self.wf_spec.get_output_on_error(), final_context ) except exc.MistralException as e: msg = ( "Failed to evaluate expression in output-on-error! " "(output-on-error: '%s', exception: '%s' Cause: '%s'" % (self.wf_spec.get_output_on_error(), e, msg) ) LOG.error(msg) self.set_state(states.ERROR, state_info=msg) # When we set an ERROR state we should safely set output value getting # w/o exceptions due to field size limitations. msg = utils.cut_by_kb( msg, cfg.CONF.engine.execution_field_size_limit_kb ) self.wf_ex.output = merge_dicts({'result': msg}, output_on_error) if self.wf_ex.task_execution_id: self._schedule_send_result_to_parent_workflow()
def _succeed_workflow(self, final_context, msg=None): self.wf_ex.output = data_flow.evaluate_workflow_output( self.wf_ex, self.wf_spec.get_output(), final_context) # Set workflow execution to success until after output is evaluated. self.set_state(states.SUCCESS, msg) if self.wf_ex.task_execution_id: self._send_result_to_parent_workflow()
def succeed_workflow(wf_ex, final_context): set_execution_state(wf_ex, states.SUCCESS) wf_spec = spec_parser.get_workflow_spec(wf_ex.spec) wf_ex.output = data_flow.evaluate_workflow_output(wf_spec, final_context) if wf_ex.task_execution_id: _schedule_send_result_to_parent_workflow(wf_ex)
def succeed_workflow(wf_ex, final_context, state_info=None): set_execution_state(wf_ex, states.SUCCESS, state_info) wf_spec = spec_parser.get_workflow_spec(wf_ex.spec) wf_ex.output = data_flow.evaluate_workflow_output(wf_spec, final_context) if wf_ex.task_execution_id: _schedule_send_result_to_parent_workflow(wf_ex) return wf_ex
def _succeed_workflow(self, final_context, msg=None): self.wf_ex.output = data_flow.evaluate_workflow_output( self.wf_spec, final_context ) # Set workflow execution to success until after output is evaluated. self.set_state(states.SUCCESS, msg) if self.wf_ex.task_execution_id: self._schedule_send_result_to_parent_workflow()
def succeed_workflow(wf_ex, final_context, wf_spec, state_info=None): # Fail workflow if output is not successfully evaluated. try: wf_ex.output = data_flow.evaluate_workflow_output( wf_spec, final_context) except Exception as e: return fail_workflow(wf_ex, e.message) # Set workflow execution to success until after output is evaluated. set_workflow_state(wf_ex, states.SUCCESS, state_info) if wf_ex.task_execution_id: _schedule_send_result_to_parent_workflow(wf_ex) return wf_ex
def _fail_workflow(self, final_context, msg): if states.is_paused_or_completed(self.wf_ex.state): return output_on_error = {} try: output_on_error = data_flow.evaluate_workflow_output( self.wf_ex, self.wf_spec.get_output_on_error(), final_context ) except exc.MistralException as e: msg = ( "Failed to evaluate expression in output-on-error! " "(output-on-error: '%s', exception: '%s' Cause: '%s'" % (self.wf_spec.get_output_on_error(), e, msg) ) LOG.error(msg) if not self.set_state(states.ERROR, state_info=msg): return # When we set an ERROR state we should safely set output value getting # w/o exceptions due to field size limitations. length_output_on_error = len(str(output_on_error).encode("utf-8")) total_output_length = utils.get_number_of_chars_from_kilobytes( cfg.CONF.engine.execution_field_size_limit_kb) if length_output_on_error < total_output_length: msg = utils.cut_by_char( msg, total_output_length - length_output_on_error ) else: msg = utils.cut_by_kb( msg, cfg.CONF.engine.execution_field_size_limit_kb ) self.wf_ex.output = merge_dicts({'result': msg}, output_on_error) # Publish event. self.notify(events.WORKFLOW_FAILED) if self.wf_ex.task_execution_id: self._send_result_to_parent_workflow()
def _succeed_workflow(self, final_context, msg=None): output = data_flow.evaluate_workflow_output(self.wf_ex, self.wf_spec.get_output(), final_context) # Set workflow execution to success after output is evaluated. if not self.set_state(states.SUCCESS, msg): return self.wf_ex.output = output # Publish event. self.notify(events.WORKFLOW_SUCCEEDED) if self.wf_ex.task_execution_id: self._send_result_to_parent_workflow()
def succeed_workflow(wf_ex, final_context, wf_spec, state_info=None): # Fail workflow if output is not successfully evaluated. try: wf_ex.output = data_flow.evaluate_workflow_output( wf_spec, final_context ) except Exception as e: return fail_workflow(wf_ex, e.message) # Set workflow execution to success until after output is evaluated. set_execution_state(wf_ex, states.SUCCESS, state_info) if wf_ex.task_execution_id: _schedule_send_result_to_parent_workflow(wf_ex) return wf_ex
def _succeed_workflow(self, final_context, msg=None): output = data_flow.evaluate_workflow_output( self.wf_ex, self.wf_spec.get_output(), final_context ) # Set workflow execution to success after output is evaluated. if not self.set_state(states.SUCCESS, msg): return self.wf_ex.output = output # Publish event. self.notify(events.WORKFLOW_SUCCEEDED) if self.wf_ex.task_execution_id: self._send_result_to_parent_workflow()