Skip to content

Commit

Permalink
fix security issue for retry package
Browse files Browse the repository at this point in the history
Signed-off-by: dentiny <dentinyhao@gmail.com>
  • Loading branch information
dentiny committed Nov 16, 2024
1 parent 4dc514e commit e99dbb1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
38 changes: 38 additions & 0 deletions python/ray/util/retry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Utils on retry."""

import time
from functools import wraps

_RAY_DEFAULT_MAX_RETRY_COUNT = 10
_RAY_DEFAULT_INIT_DELAY_SEC = 1
_RAY_DEFAULT_MAX_DELAY_SEC = 30
_RAY_DEFAULT_BACKOFF = 2
_RAT_DEFAULT_JITTER_SEC = 1


def retry(
max_retry_count=_RAY_DEFAULT_MAX_RETRY_COUNT,
init_delay_sec=_RAY_DEFAULT_INIT_DELAY_SEC,
max_delay_sec=_RAY_DEFAULT_MAX_DELAY_SEC,
backoff=_RAY_DEFAULT_BACKOFF,
jitter_sec=_RAT_DEFAULT_JITTER_SEC,
):
def wrapper(fn):
@wraps(fn)
def wrapped(*args, **kwargs):
for cur_retry_count in range(max_retry_count):
try:
return fn(*args, **kwargs)
except Exception:
if cur_retry_count + 1 == max_retry_count:
raise
else:
sleep_sec = min(
init_delay_sec * (backoff**cur_retry_count) + jitter_sec,
max_delay_sec,
)
time.sleep(sleep_sec)

return wrapped

return wrapper
4 changes: 2 additions & 2 deletions release/ray_release/cluster_manager/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ray_release.logger import logger
from ray_release.cluster_manager.cluster_manager import ClusterManager
from ray_release.util import format_link, anyscale_cluster_env_build_url
from retry import retry
from ray.util import retry

REPORT_S = 30.0

Expand All @@ -20,7 +20,7 @@ class MinimalClusterManager(ClusterManager):
Builds app config and compute template but does not start or stop session.
"""

@retry((ClusterEnvCreateError), delay=10, jitter=5, tries=2)
@retry(init_delay_sec=10, jitter_sec=5, max_retry_count=2)
def create_cluster_env(self):
assert self.cluster_env_id is None

Expand Down
4 changes: 0 additions & 4 deletions release/requirements_buildkite.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1539,10 +1539,6 @@ requests-toolbelt==1.0.0 \
--hash=sha256:7681a0a3d047012b5bdc0ee37d7f8f07ebe76ab08caeccfc3921ce23c88d5bc6 \
--hash=sha256:cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06
# via twine
retry==0.9.2 \
--hash=sha256:ccddf89761fa2c726ab29391837d4327f819ea14d244c232a1d24c67a2f98606 \
--hash=sha256:f8bfa8b99b69c4506d6f5bd3b0aabf77f98cdb17f3c9fc3f5ca820033336fba4
# via -r release/requirements_buildkite.in
rfc3986==2.0.0 \
--hash=sha256:50b1502b60e289cb37883f3dfd34532b8873c7de9f49bb546641ce9cbd256ebd \
--hash=sha256:97aacf9dbd4bfd829baad6e6309fa6573aaf1be3f6fa735c8ab05e46cecb261c
Expand Down

0 comments on commit e99dbb1

Please sign in to comment.