Beispiel #1
0
def parse_tensorboard(tensorboard):
    """
    Process the Tensorboard object and format it as the UI expects it.
    """
    if tensorboard.get("status", {}).get("readyReplicas", 0) == 1:
        phase = status.STATUS_PHASE.READY
        message = "The Tensorboard server is ready to connect"
        key = "tensorboard.backend.serverReady"
    else:
        phase = status.STATUS_PHASE.UNAVAILABLE
        message = "The Tensorboard server is currently unavailble"
        key = "tensorboard.backend.serverUnavailable"

    parsed_tensorboard = {
        "name":
        tensorboard["metadata"]["name"],
        "namespace":
        tensorboard["metadata"]["namespace"],
        "logspath":
        tensorboard["spec"]["logspath"],
        "age":
        tensorboard["metadata"]["creationTimestamp"],
        "status":
        status.create_status(phase,
                             message,
                             "",
                             key={
                                 "key": key,
                                 "params": None
                             })
    }

    return parsed_tensorboard
Beispiel #2
0
def pvc_status(pvc):
    """
    Set the status of the pvc
    """
    if pvc.metadata.deletion_timestamp is not None:
        return status.create_status(status.STATUS_PHASE.TERMINATING,
                                    "Deleting Volume...")

    if pvc.status.phase == "Bound":
        return status.create_status(status.STATUS_PHASE.READY, "Bound")

    # The PVC is in Pending state, we check the Events to find out why
    evs = api.v1_core.list_namespaced_event(
        namespace=pvc.metadata.namespace,
        field_selector=api.events_field_selector(
            "PersistentVolumeClaim", pvc.metadata.name
        ),
    ).items

    # If there are no events, then the PVC was just created
    if len(evs) == 0:
        return status.create_status(status.STATUS_PHASE.WAITING,
                                    "Provisioning Volume...")

    msg = f"Pending: {evs[0].message}"
    state = evs[0].reason
    if evs[0].reason == "WaitForFirstConsumer":
        phase = status.STATUS_PHASE.UNAVAILABLE
        msg = (
            "Pending: This volume will be bound when its first consumer"
            " is created. E.g., when you first browse its contents, or"
            " attach it to a notebook server"
        )
    elif evs[0].reason == "Provisioning":
        phase = status.STATUS_PHASE.WAITING
    elif evs[0].reason == "FailedBinding":
        phase = status.STATUS_PHASE.WARNING
    elif evs[0].type == "Warning":
        phase = status.STATUS_PHASE.WARNING
    elif evs[0].type == "Normal":
        phase = status.STATUS_PHASE.READY

    return status.create_status(phase, msg, state)
Beispiel #3
0
def parse_tensorboard(tensorboard):
    """
    Process the Tensorboard object and format it as the UI expects it.
    """

    if tensorboard.get("status", {}).get("readyReplicas", 0) == 1:
        phase = status.STATUS_PHASE.READY
        message = "The Tensorboard server is ready to connect"
    else:
        phase = status.STATUS_PHASE.UNAVAILABLE
        message = "The Tensorboard server is currently unavailble"

    parsed_tensorboard = {
        "name": tensorboard["metadata"]["name"],
        "namespace": tensorboard["metadata"]["namespace"],
        "logspath": tensorboard["spec"]["logspath"],
        "age": helpers.get_age(tensorboard),
        "status": status.create_status(phase, message, "")
    }

    return parsed_tensorboard
Beispiel #4
0
def process_status(notebook):
    """
    Return status and reason. Status may be [running|waiting|warning|error]
    """
    # Check if the Notebook is stopped
    readyReplicas = notebook.get("status", {}).get("readyReplicas", 0)
    metadata = notebook.get("metadata", {})
    annotations = metadata.get("annotations", {})

    if STOP_ANNOTATION in annotations:
        if readyReplicas == 0:
            return status.create_status(
                status.STATUS_PHASE.STOPPED,
                "No Pods are currently running for this Notebook Server.",
            )
        else:
            return status.create_status(status.STATUS_PHASE.TERMINATING,
                                        "Notebook Server is stopping.")

    # If the Notebook is being deleted, the status will be waiting
    if "deletionTimestamp" in metadata:
        return status.create_status(status.STATUS_PHASE.TERMINATING,
                                    "Deleting this notebook server")

    # Check the status
    state = notebook.get("status", {}).get("containerState", "")

    # Use conditions on the Jupyter notebook (i.e., s) to determine overall
    # status. If no container state is available, we try to extract information
    # about why the notebook is not starting from the notebook's events
    # (see find_error_event)
    if readyReplicas == 1:
        return status.create_status(status.STATUS_PHASE.READY, "Running")

    if "waiting" in state:
        return status.create_status(status.STATUS_PHASE.WAITING,
                                    state["waiting"]["reason"])

    # Provide the user with detailed information (if any) about
    # why the notebook is not starting
    notebook_events = get_notebook_events(notebook)
    status_val, reason = status.STATUS_PHASE.WAITING, "Scheduling the Pod"
    status_event, reason_event = find_error_event(notebook_events)
    if status_event is not None:
        status_val, reason = status_event, reason_event

    return status.create_status(status_val, reason)