Cap maximum evaluation period and granularity

to avoid overflow errors caused by too long integers.

Closes-Bug: #1315819
Change-Id: I502f9373d2572d9b7819fd779ff38b7562e2df31
This commit is contained in:
Takashi Kajinami 2025-03-13 00:45:58 +09:00
parent 60ef9dd1b9
commit 7b369efc1c
2 changed files with 5 additions and 2 deletions

View File

@ -59,10 +59,12 @@ class AlarmGnocchiThresholdRule(base.AlarmRule):
aggregation_method = wsme.wsattr(wtypes.text, mandatory=True)
"The aggregation_method to compare to the threshold"
evaluation_periods = wsme.wsattr(wtypes.IntegerType(minimum=1), default=1)
evaluation_periods = wsme.wsattr(wtypes.IntegerType(
minimum=1, maximum=100), default=1)
"The number of historical periods to evaluate the threshold"
granularity = wsme.wsattr(wtypes.IntegerType(minimum=1), default=60)
granularity = wsme.wsattr(wtypes.IntegerType(
minimum=1, maximum=3600 * 24 * 365), default=60)
"The time range in seconds over which query"
cache = cachetools.TTLCache(maxsize=1, ttl=3600)

View File

@ -36,6 +36,7 @@ COMPARATORS = {
OPTS = [
cfg.IntOpt('additional_ingestion_lag',
min=0,
max=3600 * 24,
default=0,
help='The number of seconds to extend the evaluation windows '
'to compensate the reporting/ingestion lag.')