Skip to content

Commit

Permalink
added min_check for timeframe duratiion
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-Robusta committed Sep 4, 2023
1 parent a3c006d commit ee6d265
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ def __init__(self, config: Config) -> None:
self._metrics_service_loaders: dict[Optional[str], Union[PrometheusMetricsLoader, Exception]] = {}
self._metrics_service_loaders_error_logged: set[Exception] = set()
self._strategy = self.config.create_strategy()

# eks has a lower step limit than other types of prometheus, it will throw an error
if config.eks_managed_prom and self._strategy.settings.timeframe_duration < 2:
self._strategy.settings.timeframe_duration = 2

# This executor will be running calculations for recommendations
self._executor = ThreadPoolExecutor(self.config.max_workers)
Expand Down Expand Up @@ -210,6 +206,13 @@ async def run(self) -> None:
return

try:
# eks has a lower step limit than other types of prometheus, it will throw an error
step_count = self._strategy.settings.history_duration * 60 / self._strategy.settings.timeframe_duration
if self.config.eks_managed_prom and step_count > 10000:
min_step = self._strategy.settings.history_duration * 60 / 10000
self.warning(f"The timeframe duration provided is insufficient and will be overridden with {min_step}. Kindly adjust --timeframe_duration to a value equal to or greater than {min_step}.")
self._strategy.settings.timeframe_duration = min_step

result = await self._collect_result()
self._process_result(result)
except ClusterNotSpecifiedException as e:
Expand Down

0 comments on commit ee6d265

Please sign in to comment.