Skip to content

Commit

Permalink
feat(oracle): raise PycloudlibTimeoutError from wait_till_ready
Browse files Browse the repository at this point in the history
Raising a timeout exception instead of a generic exception allows
for consumers of pycloudlib to retry when instance launching fails
due to timing out. This is important when trying to launch BM
instances which can sometimes fail to provision even when the
Oracle API reports their being sufficient capacity.
  • Loading branch information
a-dubs committed Jan 17, 2025
1 parent 72ebfce commit 59a2372
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pycloudlib/oci/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from oci.retry import DEFAULT_RETRY_STRATEGY # pylint: disable=E0611,E0401

from pycloudlib.errors import PycloudlibError
from pycloudlib.errors import PycloudlibError, PycloudlibTimeoutError

if TYPE_CHECKING:
import oci
Expand All @@ -33,6 +33,8 @@ def wait_till_ready(
func_kwargs: Dictionary with keyword arguments to pass to the function
Returns:
The updated version of the current_data
Raises:
PycloudlibTimeoutError: If the desired state is not reached in time
"""
if func_kwargs is None:
func_kwargs = {}
Expand All @@ -42,7 +44,7 @@ def wait_till_ready(
if current_data.lifecycle_state == desired_state:
return current_data
time.sleep(1)
raise PycloudlibError(
raise PycloudlibTimeoutError(
"Expected {} state, but found {} after waiting {} seconds. "
"Check OCI console for more details".format(
desired_state, current_data.lifecycle_state, sleep_seconds
Expand Down

0 comments on commit 59a2372

Please sign in to comment.