-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: repackage 412 Harbor error into a user-friendly error (#926)
Signed-off-by: SdgJlbl <sarah.diot-girard@owkin.com>
- Loading branch information
Showing
8 changed files
with
94 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
|
||
import orchestrator.mock as orc_mock | ||
from builder.exceptions import BuildRetryError | ||
from substrapp.compute_tasks.errors import CeleryNoRetryError | ||
from substrapp.docker_registry import RegistryPreconditionFailedException | ||
from substrapp.tasks.tasks_save_image import save_image_task | ||
|
||
CHANNEL = "mychannel" | ||
|
||
|
||
def test_tasks_save_image_random_exception(celery_app, celery_worker, mocker): | ||
mocker.patch("image_transfer.make_payload", side_effect=Exception("random error")) | ||
function = orc_mock.FunctionFactory() | ||
with pytest.raises(CeleryNoRetryError): | ||
r = save_image_task.apply_async( | ||
kwargs={"function_serialized": function.model_dump_json(), "channel_name": CHANNEL} | ||
) | ||
r.get() | ||
|
||
|
||
def test_tasks_save_image_412_exception(celery_app, celery_worker, mocker): | ||
mocker.patch("image_transfer.make_payload", side_effect=RegistryPreconditionFailedException) | ||
function = orc_mock.FunctionFactory() | ||
with pytest.raises(BuildRetryError): | ||
r = save_image_task.apply( | ||
kwargs={"function_serialized": function.model_dump_json(), "channel_name": CHANNEL}, retries=1 | ||
) | ||
r.get() |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Repackage Harbor 412 errors to a user-friendly message. |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Errors when saving the image to the registry are properly handled. |