change max duration to 10 years
This commit is contained in:
parent
5ed5a4aa08
commit
a1f701d2ba
2 changed files with 9 additions and 9 deletions
|
@ -16,6 +16,8 @@ from matrix_alertbot.errors import (
|
|||
SilenceNotFoundError,
|
||||
)
|
||||
|
||||
MAX_DURATION_DAYS = 3652
|
||||
|
||||
|
||||
class AlertmanagerClient:
|
||||
def __init__(self, url: str, cache: Cache) -> None:
|
||||
|
@ -69,14 +71,12 @@ class AlertmanagerClient:
|
|||
]
|
||||
|
||||
start_time = datetime.now()
|
||||
if duration_seconds is None:
|
||||
end_time = datetime.max
|
||||
max_duration = timedelta(days=MAX_DURATION_DAYS)
|
||||
if duration_seconds is None or duration_seconds > max_duration.total_seconds():
|
||||
end_time = start_time + max_duration
|
||||
elif duration_seconds > 0:
|
||||
try:
|
||||
duration_delta = timedelta(seconds=duration_seconds)
|
||||
end_time = start_time + duration_delta
|
||||
except OverflowError:
|
||||
end_time = datetime.max
|
||||
else:
|
||||
raise InvalidDurationError(f"Duration must be positive: {duration_seconds}")
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ class AlertmanagerClientTestCase(unittest.IsolatedAsyncioTestCase):
|
|||
],
|
||||
"createdBy": "user",
|
||||
"startsAt": "1970-01-01T00:00:00",
|
||||
"endsAt": "9999-12-31T23:59:59.999999",
|
||||
"endsAt": "1980-01-01T00:00:00",
|
||||
"comment": "Acknowledge alert from Matrix",
|
||||
},
|
||||
silence,
|
||||
|
@ -461,7 +461,7 @@ class AlertmanagerClientTestCase(unittest.IsolatedAsyncioTestCase):
|
|||
],
|
||||
"createdBy": "user",
|
||||
"startsAt": "1970-01-01T00:00:00",
|
||||
"endsAt": "9999-12-31T23:59:59.999999",
|
||||
"endsAt": "1980-01-01T00:00:00",
|
||||
"comment": "Acknowledge alert from Matrix",
|
||||
},
|
||||
silence,
|
||||
|
|
Loading…
Reference in a new issue