Exemplo n.º 1
0
 def _task_listener(state, details):
     """Store the result of the task under the given flow in the log
     book so that it can be retrieved later.
     """
     runner = details['runner']
     flow = details['flow']
     LOG.debug("Recording %s of %s has finished state %s",
               runner, flow, state)
     metadata = {}
     flow_details = self._logbook[flow.uuid]
     if state in (states.SUCCESS, states.FAILURE):
         metadata['result'] = runner.result
     if runner.uuid not in flow_details:
         metadata['states'] = [state]
         metadata['version'] = runner.version
         flow_details.add_task(runner.uuid, metadata)
     else:
         details = flow_details[runner.uuid]
         immediate_version = runner.version
         recorded_version = details.metadata.get('version')
         if recorded_version is not None:
             if not utils.is_version_compatible(recorded_version,
                                                immediate_version):
                 LOG.warn("Updating a task with a different version"
                          " than the one being listened to (%s != %s)",
                          recorded_version, immediate_version)
         past_states = details.metadata.get('states', [])
         if state not in past_states:
             past_states.append(state)
             details.metadata['states'] = past_states
         if metadata:
             details.metadata.update(metadata)
Exemplo n.º 2
0
 def _get_details(self, flow_details, runner):
     if runner.uuid not in flow_details:
         return (False, None)
     details = flow_details[runner.uuid]
     has_completed = False
     for state in details.metadata.get('states', []):
         if state in (states.SUCCESS, states.FAILURE):
             has_completed = True
             break
     if not has_completed:
         return (False, None)
     immediate_version = runner.version
     recorded_version = details.metadata.get('version')
     if recorded_version is not None:
         if not utils.is_version_compatible(recorded_version,
                                            immediate_version):
             LOG.warn("Fetching runner metadata from a task with"
                      " a different version from the one being"
                      " processed (%s != %s)", recorded_version,
                      immediate_version)
             details = self._reconcile_versions(immediate_version, details)
     return (True, details)