Skip to content

Commit

Permalink
Added response limit to method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredeen committed Sep 10, 2024
1 parent 417fb74 commit 7c784d4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions serve_event_listener/status_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,17 @@ def set_k8s_api_client(self, k8s_api_client: client.CoreV1Api, namespace: str):
self.k8s_api_client = k8s_api_client
self.namespace = namespace

def fetch_status_from_k8s_api(self, release: str) -> Tuple[str, str, str]:
def fetch_status_from_k8s_api(
self, release: str, response_limit: int = 1000
) -> Tuple[str, str, str]:
"""
Get the actual status of a release from k8s via the client API.
Because this can be as costly operation it is only used at critical times such as deleted pods.
Parameters:
- release (str): The release
- response_limit (int): The maximum number of objects to return from the k8s API call.
Returns:
- Tuple[str, str, str]: The status of the pod, container message, pod message
Expand All @@ -141,7 +147,7 @@ def fetch_status_from_k8s_api(self, release: str) -> Tuple[str, str, str]:

try:
api_response = self.k8s_api_client.list_namespaced_pod(
self.namespace, limit=500, timeout_seconds=120, watch=False
self.namespace, limit=response_limit, timeout_seconds=120, watch=False
)

for pod in api_response.items:
Expand Down

0 comments on commit 7c784d4

Please sign in to comment.