InseeFrLab/onyxia-api

Fetching logs fail if pod has more than one container

Opened this issue · 1 comments

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)

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

  • fetching all the related pods ( iterrating over ownerReferences and finding in the helm manifest the controller ). Our handling is bad at the moment (annotation look up without perfect assurance )
  • provide all containers names
  • provide a new endpoints for logs of a container in a pod
    @olevitt