File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828
2929from .clients import connection , zun
3030from .context import session
31- from .exception import ContainerCreateWaitError , ServiceError
31+ from .exception import ContainerCreateWaitError , ResourceError , ServiceError
3232from .network import bind_floating_ip , get_free_floating_ip
3333
3434DEFAULT_IMAGE_DRIVER = "docker"
@@ -131,7 +131,7 @@ def submit(
131131 idempotent (bool, optional): Whether to update the existing container if it already exists. Defaults to False.
132132
133133 Raises:
134- ContainerCreateWaitError : If the container creation fails.
134+ ResourceError : If the container creation fails.
135135
136136 Returns:
137137 None
@@ -169,7 +169,7 @@ def submit(
169169 # ensure container object gets params even on error
170170 self .id = exc .zun_container .uuid
171171 self ._status = exc .zun_container .status
172- raise
172+ raise ResourceError ( message = exc . zun_container . status_reason ) from exc
173173
174174 if wait_for_active and self .status != "Running" :
175175 self .wait (status = "Running" , timeout = wait_timeout )
Original file line number Diff line number Diff line change @@ -30,13 +30,16 @@ def __init__(self, message):
3030 super ().__init__ (message )
3131
3232
33- class ContainerCreateWaitError (RuntimeError ):
33+ class ContainerCreateWaitError (ResourceError ):
3434 """Raised when Zun creates a container but waiting for target status fails."""
3535
3636 def __init__ (self , zun_container , cause ):
3737 self .zun_container = zun_container
3838 self .cause = cause
3939 message = (
40- f"Container { self .zun_container .uuid } was created, but waiting for target status failed: { cause } "
40+ "Container {} was created, but waiting for target status failed: {}" .format (
41+ self .zun_container .uuid ,
42+ cause ,
43+ )
4144 )
4245 super ().__init__ (message )
Original file line number Diff line number Diff line change 2121from zunclient .exceptions import Conflict
2222
2323from chi .container import Container , download , upload
24- from chi .exception import ContainerCreateWaitError
24+ from chi .exception import ContainerCreateWaitError , ResourceError
2525
2626
2727@pytest .fixture ()
@@ -170,7 +170,7 @@ def test_submit_preserves_reference_on_create_wait_failure(mocker):
170170 zun_mock = mocker .patch ("chi.container.zun" )()
171171 zun_mock .containers .get .return_value = leaked_zun_container
172172
173- with pytest .raises (ContainerCreateWaitError ):
173+ with pytest .raises (ResourceError ):
174174 chi_container .submit (wait_for_active = False , show = None )
175175
176176 assert chi_container .id == "leaked-uuid"
You can’t perform that action at this time.
0 commit comments