Skip to content

Commit

Permalink
Fixes #301
Browse files Browse the repository at this point in the history
  • Loading branch information
aantn committed Jun 28, 2024
1 parent 24af7f5 commit c757c6c
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit c757c6c

Please sign in to comment.