kubernetes.client.exceptions.ApiException:(0)原因:500内部服务器错误

py49o6xq  于 2022-12-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(229)
  • 在管道中部署dag时出现上述异常。
The log is as follows:
************************************************************************************************************
    *                                                                                                          *
    *                                                                                                          *
    *                                           Deploying 'dags'...                                            *
    *                                                                                                          *
    *                                                                                                          *
    ************************************************************************************************************
    [2022-12-16 14:09:48,076] {io} INFO - Current directory: /artifacts/dags
    [2022-12-16 14:09:48,076] {copy_deploy_tool} INFO - Deploy 'dags' by copying files...
    [2022-12-16 14:09:48,083] {deploy_tool} INFO -  saving values.yaml...
    [2022-12-16 14:09:48,162] {copy_deploy_tool} INFO - Removing files from 'development:airflow-5db795dd7c-d586h:/root/airflow/dags'
    [2022-12-16 14:09:48,264] {deploy} ERROR - Execution failed for project: dags
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/stream/ws_client.py", line 296, in websocket_call
        client = WSClient(configuration, get_websocket_url(url), headers, capture_all)
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/stream/ws_client.py", line 94, in __init__
        self.sock.connect(url, header=header)
      File "/usr/local/lib/python3.6/dist-packages/websocket/_core.py", line 253, in connect
        self.handshake_response = handshake(self.sock, *addrs, **options)
      File "/usr/local/lib/python3.6/dist-packages/websocket/_handshake.py", line 57, in handshake
        status, resp = _get_resp_headers(sock)
      File "/usr/local/lib/python3.6/dist-packages/websocket/_handshake.py", line 143, in _get_resp_headers
        raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
    websocket._exceptions.WebSocketBadStatusException: Handshake status 500 Internal Server Error
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/dist-packages/commands/deploy/deploy.py", line 65, in __try_execute
        deployment=project[DEPLOYMENT],
      File "/usr/local/lib/python3.6/dist-packages/tools/deploy/copy_deploy_tool.py", line 50, in run
        namespace, container, pod_name, command, api_client=api_client
      File "/usr/local/lib/python3.6/dist-packages/helpers/kubernetes.py", line 133, in run_pod_command
        stdout=True,
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/stream/stream.py", line 35, in stream
        return func(*args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api/core_v1_api.py", line 841, in connect_get_namespaced_pod_exec
        (data) = self.connect_get_namespaced_pod_exec_with_http_info(name, namespace, **kwargs)  # noqa: E501
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api/core_v1_api.py", line 941, in connect_get_namespaced_pod_exec_with_http_info
        collection_formats=collection_formats)
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 345, in call_api
        _preload_content, _request_timeout)
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 176, in __call_api
        _request_timeout=_request_timeout)
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/stream/stream.py", line 30, in _intercept_request_call
        return ws_client.websocket_call(config, *args, **kwargs)
      File "/usr/local/lib/python3.6/dist-packages/kubernetes/stream/ws_client.py", line 302, in websocket_call
        raise ApiException(status=0, reason=str(e))
    kubernetes.client.rest.ApiException: (0)
    Reason: Handshake status 500 Internal Server Error
    
    [2022-12-16 14:09:49,631] {shell} INFO - doi: Deployment record uploaded successfully
    [2022-12-16 14:09:49,631] {shell} INFO - OK
    [2022-12-16 14:09:49,635] {io} INFO - Current directory: /artifacts
    [2022-12-16 14:09:49,635] {pretty_info} INFO - ```
okxuctiv

okxuctiv1#

通常,当pod进入运行状态,但其上没有正在运行的容器(0/1)时会发生这种情况。如果对此pod和容器运行execute命令,则会收到500内部服务器错误,而不是与真实的问题相关的错误(容器未运行)。
检查所有容器是否正在运行。

if  all([ p.status.phase == "Running" for p in my_pods]) \
    and all([c.state.running for p in my_pods for c in p.status.container_statuses]):

另请参阅此StackpostGithub问题。

相关问题