Skip to content

Commit 5391a8d

Browse files
authored
bug fix - krr period is 0, for period under 1 day (#453)
1 parent 0c7119c commit 5391a8d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,13 @@ async def load_pods(self, object: K8sObjectData, period: timedelta) -> list[PodD
275275

276276
logger.debug(f"Adding historic pods for {object}")
277277

278-
days_literal = min(int(period.total_seconds()) // 3600 // 24, 32)
279-
period_literal = f"{days_literal}d"
278+
period_seconds = period.total_seconds()
279+
if period_seconds <= 86400: # one day
280+
hours_literal = min(int(period.total_seconds()) // 3600, 32)
281+
period_literal = f"{hours_literal}h"
282+
else:
283+
days_literal = min(int(period.total_seconds()) // 3600 // 24, 32)
284+
period_literal = f"{days_literal}d"
280285
pod_owners: Iterable[str]
281286
pod_owner_kind: str
282287
cluster_label = self.get_prometheus_cluster_label()

0 commit comments

Comments
 (0)