unikubehq / cli

The convenient command line interface (CLI) to the unikube platform. :computer:
https://unikube.io
Apache License 2.0
18 stars 1 forks source link

`app switch` causes error when retrieving serviceaccount token #208

Open SteinRobert opened 3 years ago

SteinRobert commented 3 years ago
Traceback (most recent call last):
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/stream/ws_client.py", line 468, in websocket_call
    client = WSClient(configuration, url, headers, capture_all)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/stream/ws_client.py", line 62, in __init__
    self.sock = create_websocket(configuration, url, headers)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/stream/ws_client.py", line 452, in create_websocket
    websocket.connect(url, header=header)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/websocket/_core.py", line 253, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/websocket/_handshake.py", line 57, in handshake
    status, resp = _get_resp_headers(sock)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-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/bin/unikube", line 33, in <module>
    sys.exit(load_entry_point('unikube==1.0.1.dev9', 'console_scripts', 'unikube')())
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/click/decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/src/cli/app.py", line 398, in switch
    service_account_tokens = k8s.get_serviceaccount_tokens(deployment)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/src/local/system.py", line 433, in get_serviceaccount_tokens
    response = stream(
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/stream/stream.py", line 35, in _websocket_request
    return api_method(*args, **kwargs)
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/client/api/core_v1_api.py", line 994, in connect_get_namespaced_pod_exec
    return self.connect_get_namespaced_pod_exec_with_http_info(name, namespace, **kwargs)  # noqa: E501
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/client/api/core_v1_api.py", line 1101, in connect_get_namespaced_pod_exec_with_http_info
    return self.api_client.call_api(
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 348, in call_api
    return self.__call_api(resource_path, method,
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 180, in __call_api
    response_data = self.request(
  File "/usr/local/Cellar/unikube/HEAD/libexec/lib/python3.8/site-packages/kubernetes/stream/ws_client.py", line 474, in websocket_call
    raise ApiException(status=0, reason=str(e))
kubernetes.client.exceptions.ApiException: (0)
Reason: Handshake status 500 Internal Server Error
schwobaseggl commented 2 years ago

@SteinRobert Can you provide some instructions how to reproduce this issue. @Schille Is this the issue that occurs when the container remains switched for a while and the initial token expires?

Schille commented 2 years ago

Potentially, you start the switch operation a second before the originally provided token expires. In that case requests made with this token will fail quite soon. Currently there is no ongoing process in place to fetch a new token once the initial token expires.

schwobaseggl commented 2 years ago

@Schille What is the general approach to any switch related issues? Do we leave them and wait for gefyra or do we still put efforts into fixing Telepresence-specific code?

Schille commented 2 years ago

I'd say this is not really related to Telepresenc; the same will be for naive Gefyra. We could build that service directly into Gefyra so it's not a UK cli issue anymore.