Skip to content

Commit

Permalink
fix: avoid exceed search.maxQueryLen (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlipoca9 authored Jul 24, 2024
1 parent 2fd16a3 commit 77c8c61
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,22 @@ async def load_pods(self, object: K8sObjectData, period: timedelta) -> list[PodD
pod_owners = [object.name]
pod_owner_kind = object.kind

owners_regex = "|".join(pod_owners)
related_pods_result = await self.query(
f"""
last_over_time(
kube_pod_owner{{
owner_name=~"{owners_regex}",
owner_kind="{pod_owner_kind}",
namespace="{object.namespace}"
{cluster_label}
}}[{period_literal}]
)
"""
)

related_pods_result = []
for owner_group in batched(pod_owners, 10):
owners_regex = "|".join(owner_group)
related_pods_result_item = await self.query(
f"""
last_over_time(
kube_pod_owner{{
owner_name=~"{owners_regex}",
owner_kind="{pod_owner_kind}",
namespace="{object.namespace}"
{cluster_label}
}}[{period_literal}]
)
"""
)
related_pods_result.extend(related_pods_result_item)
if related_pods_result == []:
return []

Expand Down

0 comments on commit 77c8c61

Please sign in to comment.