fix(BA-1626): Improve logging for inspecting missing containers #4784
+13
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up of #1266 and resolves #4783 (BA-1626)
This pull request refactors error handling in the
src/ai/backend/agent/docker/agent.py
file by replacing hardcoded HTTP status codes with theHTTPStatus
enumeration for improved readability and maintainability. Additionally, logging behavior has been adjusted to ensure better clarity when handling specific Docker errors.Refactoring HTTP status codes:
src/ai/backend/agent/docker/agent.py
: Replaced hardcoded HTTP status codes (404
and409
) withHTTPStatus.NOT_FOUND
andHTTPStatus.CONFLICT
in multiple methods (_fetch_container_info
,check_image
,destroy_kernel
, andlog_iter
). This improves code readability and aligns with Python's standard library conventions. [1] [2] [3] [4] [5]Logging enhancements:
src/ai/backend/agent/docker/agent.py
: Adjusted logging behavior in error handling to provide clearer warnings when Docker errors occur, such as containers not found or already cleaned. [1] [2] [3]Checklist: (if applicable)