You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Develop an API endpoint to retrieve logs from a container running in a workspace.
This API should support retrieving both the current and 'previous' log and provide a real-time log view option.
Key features:
Retrieve logs of a container in a workspace.
Fetch real-time logs from a container.
Support fetching logs from a previously terminated container run.
Limit the size of the fetched logs.
RBAC - only authorized users can view the logs
No sensitive data is exposed.
Suggested Implementation:
API Endpoints:
For log pagination and old log retrieval: PATH: GET /api/v1/workspaces/{namespace}/{name}/details/log Query Parameters:
container (required): The name of the container for which logs are requested.
previous (optional): Fetch logs from the previously terminated container.
offset (optional): The starting point for pagination. It indicates the number of lines to skip (default: end_of_file - limit or 0, whichever is larger).
limit (optional): The number of lines to retrieve (default: 100, max limit: 1,000).
Real time log retrieval:
Implement Server-Sent Events (SSE)/WS for streaming.
Add 'previous' query parameter
Adding query parameter to indicate previous log retrieval.
The pod container list data should include for each container if 'previous log' exists, so the option is disabled for containers that doesn't have previous log. in case of API called for container with no previous log, the API returns:
HTTP 400 Bad Request → "No previous logs available for this container."
Size of the log
Limit the response to a maximum of 1,000 lines of log data.
RBAC
Only workspace owner and contributors can view the logs.
Sensitive data
By default, no sensitive data will be filtered.
Possible enhancement:
Since container patterns are not predictable (We don't have control on which containers will run as part of the workspace), a potential solution is to add a LogFilterPatterns field to the WorkspaceKind and allow admins to configure filters for the workspace. These filters will be used by the backend to mask sensitive data.
Log rotation
Users will only have access to the latest logs and will not be able to access older logs after rotation.
The text was updated successfully, but these errors were encountered:
Now that #210 is merged, the status of the Workspace resources will look something like this, which can be used by the backend to know if the pod exists, and what containers it has:
This new status field will look something like (when the Pod exists):
Summary
Develop an API endpoint to retrieve logs from a container running in a workspace.
This API should support retrieving both the current and 'previous' log and provide a real-time log view option.
Key features:
Suggested Implementation:
API Endpoints:
For log pagination and old log retrieval:
PATH: GET
/api/v1/workspaces/{namespace}/{name}/details/log
Query Parameters:
container
(required): The name of the container for which logs are requested.previous
(optional): Fetch logs from the previously terminated container.offset
(optional): The starting point for pagination. It indicates the number of lines to skip (default:end_of_file - limit
or 0, whichever is larger).limit
(optional): The number of lines to retrieve (default: 100, max limit: 1,000).Response:
{ "logs": [], "pagination": { "offsetFrom": start_index, "offsetTo": end_index, "endOfFile": bool }
For log streaming:
PATH: GET
/api/v1/workspaces/{namespace}/{name}/details/log/stream
Query Parameters:
container
(required): The name of the container for which logs are requested.sinceTime
(optional): Retrieve logs after a specified timestamp.Response:
{ "logs": [], "referenceTimestamp": last_timestamp_sent }
Real time log retrieval:
Implement Server-Sent Events (SSE)/WS for streaming.
Add 'previous' query parameter
Adding query parameter to indicate previous log retrieval.
The pod container list data should include for each container if 'previous log' exists, so the option is disabled for containers that doesn't have previous log. in case of API called for container with no previous log, the API returns:
HTTP 400 Bad Request → "No previous logs available for this container."
Size of the log
Limit the response to a maximum of 1,000 lines of log data.
RBAC
Only workspace owner and contributors can view the logs.
Sensitive data
By default, no sensitive data will be filtered.
Possible enhancement:
Since container patterns are not predictable (We don't have control on which containers will run as part of the workspace), a potential solution is to add a LogFilterPatterns field to the WorkspaceKind and allow admins to configure filters for the workspace. These filters will be used by the backend to mask sensitive data.
Log rotation
Users will only have access to the latest logs and will not be able to access older logs after rotation.
The text was updated successfully, but these errors were encountered: