(self)
return msg, action, detail
Returns the most relevant status string and failed action.

    This string is meant for display only.

    Returns:
      A triple of:
      - printable status message
      - the action that failed (if any)
      - a detail message (if available)
Returns the most relevant status string and failed action.
Returns the most relevant status string and failed action .
def _operation_status_message(self):
    """Returns the most relevant status string and failed action.

    This string is meant for display only.

    Returns:
      A triple of:
      - printable status message
      - the action that failed (if any)
      - a detail message (if available)
    """
    msg = None
    action = None
    detail = None

    if not google_v2_operations.is_done(self._op):
      last_event = google_v2_operations.get_last_event(self._op)
      if last_event:
        if google_v2_operations.is_worker_assigned_event(last_event):
          msg = 'VM starting (awaiting worker checkin)'
          detail = last_event['description']
        elif google_v2_operations.is_pull_started_event(last_event):
          detail = last_event['description']
          msg = detail.replace('Started pulling', 'Pulling')
        else:
          msg = last_event['description']
          action_id = last_event.get('details', {}).get('actionId')
          if action_id:
            action = google_v2_operations.get_action_by_id(self._op, action_id)
      else:
        msg = 'Pending'

    elif google_v2_operations.is_success(self._op):
      msg = 'Success'

    else:
      # We have a failure condition and want to get the best details of why.

      # For a single failure, we may get multiple failure events.
      # For the Life Sciences v2 provider, events may look like:

      # - description: 'Execution failed: generic::failed_precondition: ...
      #   failed:
      #     cause: 'Execution failed: generic::failed_precondition: while ...
      #     code: FAILED_PRECONDITION
      #   timestamp: '2020-09-28T23:10:09.364365339Z'
      # - description: Unexpected exit status 127 while running "user-command"
      #   timestamp: '2020-09-28T23:10:04.671139036Z'
      #   unexpectedExitStatus:
      #     actionId: 4
      #     exitStatus: 127
      # - containerStopped:
      #     actionId: 4
      #     exitStatus: 127
      #     stderr: |
      #       bash: line 3: /mnt/data/script/foo: No such file or directory
      #   description: 'Stopped running "user-command": exit status 127: ...
      #   timestamp: '2020-09-28T23:10:04.671133099Z'

      # If we can get a containerStopped event, it has the best information
      # Otherwise fallback to unexpectedExitStatus.
      # Otherwise fallback to failed.

      container_failed_events = google_v2_operations.get_container_stopped_error_events(
          self._op)
      unexpected_exit_events = google_v2_operations.get_unexpected_exit_events(
          self._op)
      failed_events = google_v2_operations.get_failed_events(self._op)

      if container_failed_events:
        container_failed_event = container_failed_events[-1]
        action_id = google_v2_operations.get_event_action_id(
            container_failed_event)
        msg = google_v2_operations.get_event_description(container_failed_event)
        detail = google_v2_operations.get_event_stderr(container_failed_event)

      elif unexpected_exit_events:
        unexpected_exit_event = unexpected_exit_events[-1]
        action_id = google_v2_operations.get_event_action_id(
            unexpected_exit_event)
        msg = google_v2_operations.get_event_description(unexpected_exit_event)

      elif failed_events:
        failed_event = failed_events[-1]
        msg = google_v2_operations.get_event_description(failed_event)
        action_id = None

      if not msg:
        error = google_v2_operations.get_error(self._op)
        if error:
          msg = error['message']

        action = google_v2_operations.get_action_by_id(self._op, action_id)

    return msg, action, detail
def _operation_status_message ( self ) : msg = None action = None detail = None if not google_v2_operations . is_done ( self . _op ) : last_event = google_v2_operations . get_last_event ( self . _op ) if last_event : if google_v2_operations . is_worker_assigned_event ( last_event ) : msg = 'VM starting (awaiting worker checkin)' detail = last_event [ 'description' ] elif google_v2_operations . is_pull_started_event ( last_event ) : detail = last_event [ 'description' ] msg = detail . replace ( 'Started pulling' , 'Pulling' ) else : msg = last_event [ 'description' ] action_id = last_event . get ( 'details' , { } ) . get ( 'actionId' ) if action_id : action = google_v2_operations . get_action_by_id ( self . _op , action_id ) else : msg = 'Pending' elif google_v2_operations . is_success ( self . _op ) : msg = 'Success' else : # We have a failure condition and want to get the best details of why. # For a single failure, we may get multiple failure events. # For the Life Sciences v2 provider, events may look like: # - description: 'Execution failed: generic::failed_precondition: ... #   failed: #     cause: 'Execution failed: generic::failed_precondition: while ... #     code: FAILED_PRECONDITION #   timestamp: '2020-09-28T23:10:09.364365339Z' # - description: Unexpected exit status 127 while running "user-command" #   timestamp: '2020-09-28T23:10:04.671139036Z' #   unexpectedExitStatus: #     actionId: 4 #     exitStatus: 127 # - containerStopped: #     actionId: 4 #     exitStatus: 127 #     stderr: | #       bash: line 3: /mnt/data/script/foo: No such file or directory #   description: 'Stopped running "user-command": exit status 127: ... #   timestamp: '2020-09-28T23:10:04.671133099Z' # If we can get a containerStopped event, it has the best information # Otherwise fallback to unexpectedExitStatus. # Otherwise fallback to failed. container_failed_events = google_v2_operations . get_container_stopped_error_events ( self . _op ) unexpected_exit_events = google_v2_operations . get_unexpected_exit_events ( self . _op ) failed_events = google_v2_operations . get_failed_events ( self . _op ) if container_failed_events : container_failed_event = container_failed_events [ - 1 ] action_id = google_v2_operations . get_event_action_id ( container_failed_event ) msg = google_v2_operations . get_event_description ( container_failed_event ) detail = google_v2_operations . get_event_stderr ( container_failed_event ) elif unexpected_exit_events : unexpected_exit_event = unexpected_exit_events [ - 1 ] action_id = google_v2_operations . get_event_action_id ( unexpected_exit_event ) msg = google_v2_operations . get_event_description ( unexpected_exit_event ) elif failed_events : failed_event = failed_events [ - 1 ] msg = google_v2_operations . get_event_description ( failed_event ) action_id = None if not msg : error = google_v2_operations . get_error ( self . _op ) if error : msg = error [ 'message' ] action = google_v2_operations . get_action_by_id ( self . _op , action_id ) return msg , action , detail