o
    bi                     @   sd   d dl mZmZ d dlm  mZ d dlm  mZ d dl	Z
d dlmZ ejZG dd dejZdS )    )RequestResponseN)HealthCheckerc                       sP   e Zd ZdZ fddZeddedefddZ	d	d
 Z
edd Z  ZS )HealthzAgentzHealth check in the agent.

    This module adds health check related endpoint to the agent to check
    local components' health.
    c                    s,   t  | t|j|j d|j | _d S )N:)super__init__r   
gcs_clientipnode_manager_port_health_checker)selfdashboard_agent	__class__ `/home/ubuntu/.local/lib/python3.10/site-packages/ray/dashboard/modules/reporter/healthz_agent.pyr      s
   
zHealthzAgent.__init__z/api/local_raylet_healthzreqreturnc              
      s   z| j  I d H }|du rtdddW S W n1 tjjyG } z#|jtjjtjj	tjj
fvr=tdd| dW  Y d }~S W Y d }~nd }~ww tdddS )	NFi  zLocal Raylet failed)statustextzHealth check failed due to: successzapplication/text)r   content_type)r   check_local_raylet_livenessr   ray
exceptionsRpcErrorrpc_code_rayletGRPC_STATUS_CODE_UNAVAILABLEGRPC_STATUS_CODE_UNKNOWN"GRPC_STATUS_CODE_DEADLINE_EXCEEDED)r   r   aliveer   r   r   health_check   s(   zHealthzAgent.health_checkc                    s   d S )Nr   )r   serverr   r   r   run1   s   zHealthzAgent.runc                   C   s   dS )NFr   r   r   r   r   is_minimal_module4   s   zHealthzAgent.is_minimal_module)__name__
__module____qualname____doc__r   routesgetr   r   r$   r&   staticmethodr'   __classcell__r   r   r   r   r      s    r   )aiohttp.webr   r   ray.dashboard.optional_utils	dashboardoptional_utilsray.dashboard.utilsutilsdashboard_utilsray.exceptionsr   $ray.dashboard.modules.reporter.utilsr   DashboardAgentRouteTabler,   DashboardAgentModuler   r   r   r   r   <module>   s    