Skip to content

Commit

Permalink
Minor fix for prometheus not found undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaveMyYard committed Oct 20, 2023
1 parent f64a67e commit 1dbe77a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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()

# This executor will be running calculations for recommendations
self._executor = ThreadPoolExecutor(self.config.max_workers)

Expand Down Expand Up @@ -126,7 +126,7 @@ async def _calculate_object_recommendations(self, object: K8sObjectData) -> RunR
prometheus_loader = self._get_prometheus_loader(object.cluster)

if prometheus_loader is None:
return {resource: ResourceRecommendation.undefined() for resource in ResourceType}
return {resource: ResourceRecommendation.undefined("Prometheus not found") for resource in ResourceType}

metrics = await prometheus_loader.gather_data(
object,
Expand Down Expand Up @@ -209,8 +209,10 @@ async def run(self) -> None:
# 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 > 11000:
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}.")
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()
Expand Down

0 comments on commit 1dbe77a

Please sign in to comment.