mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-09 21:49:37 +00:00
fix(sandbox): reject non-finite ownership timings (#4960)
This commit is contained in:
parent
1aa813ddb3
commit
336cd3acc4
@ -29,6 +29,7 @@ class SandboxOwnershipConfig(BaseModel):
|
||||
renewal_interval_seconds: float = Field(
|
||||
default=30.0,
|
||||
gt=0,
|
||||
allow_inf_nan=False,
|
||||
description=(
|
||||
"How often an owning instance refreshes its leases. The lease TTL is derived from this (interval x ttl_multiplier), so ownership liveness is independent of sandbox.idle_timeout: "
|
||||
"renewal keeps running even when idle cleanup is disabled (idle_timeout: 0)."
|
||||
@ -37,6 +38,7 @@ class SandboxOwnershipConfig(BaseModel):
|
||||
ttl_multiplier: float = Field(
|
||||
default=4.0,
|
||||
ge=2,
|
||||
allow_inf_nan=False,
|
||||
description="Lease TTL as a multiple of renewal_interval_seconds. At least 2, so a single missed renewal (slow host, brief Redis blip) cannot expire a live owner's lease. Default 4 tolerates three consecutive misses.",
|
||||
)
|
||||
key_prefix: str = Field(
|
||||
|
||||
@ -356,6 +356,13 @@ def test_ttl_multiplier_below_two_is_rejected():
|
||||
SandboxOwnershipConfig(ttl_multiplier=1.0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("field", ["renewal_interval_seconds", "ttl_multiplier"])
|
||||
@pytest.mark.parametrize("value", [float("inf"), float("-inf"), float("nan")])
|
||||
def test_lease_timing_rejects_non_finite_values(field, value):
|
||||
with pytest.raises(ValueError):
|
||||
SandboxOwnershipConfig(**{field: value})
|
||||
|
||||
|
||||
def test_owner_ids_are_unique_per_instance():
|
||||
"""Two workers on one host must not share an owner id."""
|
||||
assert generate_owner_id() != generate_owner_id()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user