Add endpoint for complete logs of the latest container startup (#6163)

* Add endpoint for complete logs of the latest container startup

Add endpoint that returns complete logs of the latest startup of
container, which can be used for downloading Core logs in the frontend.

Realtime filtering header is used for the Journal API and StartedAt
parameter from the Docker API is used as the reference point. This means
that any other Range header is ignored for this parameter, yet the
"lines" query argument can be used to limit the number of lines. By
default "infinite" number of lines is returned.

Closes #6147

* Implement fallback for latest logs for OS older than 16.0

Implement fallback which uses the internal CONTAINER_LOG_EPOCH metadata
added to logs created by the Docker logger. Still prefer the time-based
method, as it has lower overhead and using public APIs.

* Address review comments

* Only use CONTAINER_LOG_EPOCH for latest logs

As pointed out in the review comments, we might not be able to get the
StartedAt for add-ons that are not running. Thus we need to use the only
reliable mechanism available now, which is the container log epoch.

* Remove dead code for 'Range: realtime' header handling
This commit is contained in:
Jan Čermák
2025-09-16 11:29:28 +02:00
committed by GitHub
parent e7f3573e32
commit 2e22e1e884
11 changed files with 175 additions and 19 deletions

View File

@@ -243,6 +243,10 @@ async def test_advanced_logs(
accept=LogFormat.JOURNAL,
)
# Host logs don't have a /latest endpoint
resp = await api_client.get("/host/logs/latest")
assert resp.status == 404
async def test_advaced_logs_query_parameters(
api_client: TestClient,