InseeFrLab / onyxia-api

REST API of Onyxia
https://onyxia.sh
MIT License
23 stars 28 forks source link

Fetching logs fail if pod has more than one container #425

Open johnksv opened 4 months ago

johnksv commented 4 months ago

Expected behaviour: When you in frontend select a pod (to view logs), the logs for the main container should be displayed.

Actual behaviour: Onyxia api crash since container name is not specified, and return a 500 response. This means that the GUI just display a spinner and no logs arrive to the user. The stack trace below are an example of the stack trace that is produced

Servlet.service() for servlet [dispatcherServlet] in context with path [/api] threw exception [
Request processing failed: io.fabric8.kubernetes.client.KubernetesClientException: 
Failure executing: GET at: https://10.16.0.1:443/api/v1/namespaces/user-ssb/pods/vscode-python-gcsfuse-346384-0/log?pretty=false. 
Message: a container name must be specified for pod vscode-python-gcsfuse-346384-0, 
choose one of: [istio-init istio-proxy gke-gcsfuse-sidecar vscode-python-gcsfuse oauth2-proxy]. 
Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, 
message=a container name must be specified for pod vscode-python-gcsfuse-346384-0, 
choose one of: [istio-init istio-proxy gke-gcsfuse-sidecar vscode-python-gcsfuse oauth2-proxy], metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null,
additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).] with root cause

Suggested fix:

  1. Quick fix: show the logs of the container with the same name as the serivce (vscode-python-gcsfuse).
  2. Ability to select container in GUI. Even though this might be a bit to complex for some users, if sidecars are injected that the user has no knowladge of (e.g. istio, gcsfuse, oauth2-proxy)
fcomte commented 3 months ago

There is a little work but we are working on it with :