-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fixes issues with dy-sidecar removal by director-v2 (#3029)
* extended API to raise errors * fix service removal * pylint * fixed method spec * downgrading log message * refactor error handling and propagation * pylint * refactor to simplify error handling * cleanup * remove unsued * cleanup * fix codestyle Co-authored-by: Andrei Neagu <[email protected]>
- Loading branch information
Showing
12 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/error_handlers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
from fastapi import status | ||
from fastapi.encoders import jsonable_encoder | ||
from simcore_sdk.node_ports_common.exceptions import NodeNotFound | ||
from starlette.requests import Request | ||
from starlette.responses import JSONResponse | ||
|
||
from .errors import BaseDynamicSidecarError | ||
|
||
|
||
async def http_error_handler(_: Request, exc: BaseDynamicSidecarError) -> JSONResponse: | ||
async def http_error_handler( | ||
_: Request, exception: BaseDynamicSidecarError | ||
) -> JSONResponse: | ||
return JSONResponse( | ||
content=jsonable_encoder({"errors": [exc.message]}), status_code=exc.status | ||
content=jsonable_encoder({"errors": [exception.message]}), | ||
status_code=exception.status, | ||
) | ||
|
||
|
||
async def node_not_found_error_handler( | ||
_: Request, exception: NodeNotFound | ||
) -> JSONResponse: | ||
error_fields = dict( | ||
code="dynamic_sidecar.nodeports.node_not_found", | ||
message=f"{exception}", | ||
node_uuid=f"{exception.node_uuid}", | ||
) | ||
return JSONResponse( | ||
content=jsonable_encoder(error_fields), status_code=status.HTTP_404_NOT_FOUND | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters