From c757c6c73338387b5288742fc64faeb6f2591ce3 Mon Sep 17 00:00:00 2001 From: Robusta Runner Date: Fri, 28 Jun 2024 11:15:22 +0300 Subject: [PATCH] Fixes #301 --- robusta_krr/core/runner.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/robusta_krr/core/runner.py b/robusta_krr/core/runner.py index 787982fa..68cbeb05 100644 --- a/robusta_krr/core/runner.py +++ b/robusta_krr/core/runner.py @@ -233,22 +233,27 @@ async def _check_cluster(self, cluster: Optional[str]) -> bool: return True async def _gather_object_allocations(self, k8s_object: K8sWorkload) -> Optional[ResourceScan]: - recommendation = await self._calculate_object_recommendations(k8s_object) + try: + recommendation = await self._calculate_object_recommendations(k8s_object) - self.__progressbar.progress() + self.__progressbar.progress() - if recommendation is None: - return None - - return ResourceScan.calculate( - k8s_object, - ResourceAllocations( - requests={resource: recommendation[resource].request for resource in ResourceType}, - limits={resource: recommendation[resource].limit for resource in ResourceType}, - info={resource: recommendation[resource].info for resource in ResourceType}, - ), - ) + if recommendation is None: + return None + return ResourceScan.calculate( + k8s_object, + ResourceAllocations( + requests={resource: recommendation[resource].request for resource in ResourceType}, + limits={resource: recommendation[resource].limit for resource in ResourceType}, + info={resource: recommendation[resource].info for resource in ResourceType}, + ), + ) + except Exception as e: + logger.error(f"Failed to gather allocations for {k8s_object}") + logger.exception(e) + return None + async def _collect_result(self) -> Result: clusters = await self.connector.list_clusters() if clusters is None: @@ -314,7 +319,7 @@ async def _collect_result(self) -> Result: raise CriticalRunnerException("No successful scans were made. Check the logs for more information.") return Result( - scans=scans, + scans=successful_scans, description=self.strategy.description, strategy=StrategyData( name=str(self.strategy).lower(),