Skip to content

Commit 4ff3d54

Browse files
GitHKAndrei Neagu
andauthored
♻️ Removed unused endpoint from dynamic-sidecar (#7255)
Co-authored-by: Andrei Neagu <[email protected]>
1 parent c6b4cca commit 4ff3d54

File tree

3 files changed

+0
-175
lines changed

3 files changed

+0
-175
lines changed

services/dynamic-sidecar/openapi.json

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -229,95 +229,6 @@
229229
}
230230
}
231231
},
232-
"/v1/containers/{id}/logs": {
233-
"get": {
234-
"tags": [
235-
"containers"
236-
],
237-
"summary": "Get Container Logs",
238-
"description": "Returns the logs of a given container if found",
239-
"operationId": "get_container_logs_v1_containers__id__logs_get",
240-
"parameters": [
241-
{
242-
"name": "id",
243-
"in": "path",
244-
"required": true,
245-
"schema": {
246-
"type": "string",
247-
"title": "Id"
248-
}
249-
},
250-
{
251-
"name": "since",
252-
"in": "query",
253-
"required": false,
254-
"schema": {
255-
"type": "integer",
256-
"title": "Timestamp",
257-
"description": "Only return logs since this time, as a UNIX timestamp",
258-
"default": 0
259-
},
260-
"description": "Only return logs since this time, as a UNIX timestamp"
261-
},
262-
{
263-
"name": "until",
264-
"in": "query",
265-
"required": false,
266-
"schema": {
267-
"type": "integer",
268-
"title": "Timestamp",
269-
"description": "Only return logs before this time, as a UNIX timestamp",
270-
"default": 0
271-
},
272-
"description": "Only return logs before this time, as a UNIX timestamp"
273-
},
274-
{
275-
"name": "timestamps",
276-
"in": "query",
277-
"required": false,
278-
"schema": {
279-
"type": "boolean",
280-
"title": "Display timestamps",
281-
"description": "Enabling this parameter will include timestamps in logs",
282-
"default": false
283-
},
284-
"description": "Enabling this parameter will include timestamps in logs"
285-
}
286-
],
287-
"responses": {
288-
"200": {
289-
"description": "Successful Response",
290-
"content": {
291-
"application/json": {
292-
"schema": {
293-
"type": "array",
294-
"items": {
295-
"type": "string"
296-
},
297-
"title": "Response Get Container Logs V1 Containers Id Logs Get"
298-
}
299-
}
300-
}
301-
},
302-
"404": {
303-
"description": "Container does not exists"
304-
},
305-
"500": {
306-
"description": "Errors in container"
307-
},
308-
"422": {
309-
"description": "Validation Error",
310-
"content": {
311-
"application/json": {
312-
"schema": {
313-
"$ref": "#/components/schemas/HTTPValidationError"
314-
}
315-
}
316-
}
317-
}
318-
}
319-
}
320-
},
321232
"/v1/containers/name": {
322233
"get": {
323234
"tags": [

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rest/containers.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -199,54 +199,6 @@ async def get_containers_activity(
199199
#
200200

201201

202-
@router.get(
203-
"/containers/{id}/logs",
204-
responses={
205-
status.HTTP_404_NOT_FOUND: {
206-
"description": "Container does not exists",
207-
},
208-
status.HTTP_500_INTERNAL_SERVER_ERROR: {"description": "Errors in container"},
209-
},
210-
)
211-
@cancel_on_disconnect
212-
async def get_container_logs(
213-
request: Request,
214-
shared_store: Annotated[SharedStore, Depends(get_shared_store)],
215-
container_id: str = PathParam(..., alias="id"),
216-
since: int = Query(
217-
default=0,
218-
title="Timestamp",
219-
description="Only return logs since this time, as a UNIX timestamp",
220-
),
221-
until: int = Query(
222-
default=0,
223-
title="Timestamp",
224-
description="Only return logs before this time, as a UNIX timestamp",
225-
),
226-
timestamps: bool = Query( # noqa: FBT001
227-
default=False,
228-
title="Display timestamps",
229-
description="Enabling this parameter will include timestamps in logs",
230-
),
231-
) -> list[str]:
232-
"""Returns the logs of a given container if found"""
233-
_ = request
234-
235-
_raise_if_container_is_missing(container_id, shared_store.container_names)
236-
237-
async with docker_client() as docker:
238-
container_instance = await docker.containers.get(container_id)
239-
240-
args = {"stdout": True, "stderr": True, "since": since, "until": until}
241-
if timestamps:
242-
args["timestamps"] = True
243-
244-
container_logs: list[str] = await container_instance.log(
245-
**args
246-
) # type:ignore[call-overload]
247-
return container_logs
248-
249-
250202
@router.get(
251203
"/containers/name",
252204
responses={

services/dynamic-sidecar/tests/unit/test_api_rest_containers.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -423,35 +423,6 @@ async def test_containers_docker_status_docker_error(
423423
assert response.status_code == mock_aiodocker_containers_get, response.text
424424

425425

426-
async def test_container_inspect_logs_remove(
427-
test_client: TestClient, started_containers: list[str]
428-
):
429-
for container in started_containers:
430-
# get container logs
431-
# FIXME: slow call?
432-
response = await test_client.get(f"/{API_VTAG}/containers/{container}/logs")
433-
assert response.status_code == status.HTTP_200_OK, response.text
434-
435-
# inspect container
436-
response = await test_client.get(f"/{API_VTAG}/containers/{container}")
437-
assert response.status_code == status.HTTP_200_OK, response.text
438-
parsed_response = response.json()
439-
assert parsed_response["Name"] == f"/{container}"
440-
441-
442-
async def test_container_logs_with_timestamps(
443-
test_client: TestClient, started_containers: list[str]
444-
):
445-
for container in started_containers:
446-
print("getting logs of container", container, "...")
447-
response = await test_client.get(
448-
f"/{API_VTAG}/containers/{container}/logs",
449-
query_string={"timestamps": True},
450-
)
451-
assert response.status_code == status.HTTP_200_OK, response.text
452-
assert response.json() == []
453-
454-
455426
async def test_container_missing_container(
456427
test_client: TestClient, not_started_containers: list[str]
457428
):
@@ -461,11 +432,6 @@ def _expected_error_string(container: str) -> dict[str, str]:
461432
}
462433

463434
for container in not_started_containers:
464-
# get container logs
465-
response = await test_client.get(f"/{API_VTAG}/containers/{container}/logs")
466-
assert response.status_code == status.HTTP_404_NOT_FOUND, response.text
467-
assert response.json() == _expected_error_string(container)
468-
469435
# inspect container
470436
response = await test_client.get(f"/{API_VTAG}/containers/{container}")
471437
assert response.status_code == status.HTTP_404_NOT_FOUND, response.text
@@ -485,10 +451,6 @@ def _expected_error_string(status_code: int) -> dict[str, Any]:
485451
}
486452

487453
for container in started_containers:
488-
# get container logs
489-
response = await test_client.get(f"/{API_VTAG}/containers/{container}/logs")
490-
assert response.status_code == mock_aiodocker_containers_get, response.text
491-
assert response.json() == _expected_error_string(mock_aiodocker_containers_get)
492454

493455
# inspect container
494456
response = await test_client.get(f"/{API_VTAG}/containers/{container}")

0 commit comments

Comments
 (0)