File tree Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ def delete_pod(pod_name, namespace):
178178
179179 # Delete remaining pods
180180 pods = get_pods ()
181- for pod in pods . items :
181+ for pod in pods :
182182 futures .append (executor .submit (delete_pod , pod .metadata .name , pod .metadata .namespace ))
183183
184184 # Wait for all tasks to complete and print results
@@ -346,7 +346,7 @@ def _logs(pod_name: str, follow: bool):
346346 if pod_name == "" :
347347 try :
348348 pods = get_pods ()
349- pod_list = [item .metadata .name for item in pods . items ]
349+ pod_list = [item .metadata .name for item in pods ]
350350 except Exception as e :
351351 print (f"Could not fetch any pods in namespace { namespace } : { e } " )
352352 return
Original file line number Diff line number Diff line change 99from kubernetes import client , config , watch
1010from kubernetes .client import CoreV1Api
1111from kubernetes .client .exceptions import ApiException
12- from kubernetes .client .models import V1Namespace , V1PodList
12+ from kubernetes .client .models import V1Namespace , V1Pod , V1PodList
1313from kubernetes .dynamic import DynamicClient
1414from kubernetes .stream import stream
1515
@@ -34,19 +34,25 @@ def get_dynamic_client() -> DynamicClient:
3434 return DynamicClient (client .ApiClient ())
3535
3636
37- def get_pods () -> V1PodList :
37+ def get_pods () -> list [ V1Pod ] :
3838 sclient = get_static_client ()
39- try :
40- pod_list : V1PodList = sclient .list_namespaced_pod (get_default_namespace ())
41- except Exception as e :
42- raise e
43- return pod_list
44-
45-
46- def get_mission (mission : str ) -> list [V1PodList ]:
39+ pods : list [V1Pod ] = []
40+ namespaces = get_namespaces ()
41+ for ns in namespaces :
42+ namespace = ns .metadata .name
43+ try :
44+ pod_list : V1PodList = sclient .list_namespaced_pod (namespace )
45+ for pod in pod_list .items :
46+ pods .append (pod )
47+ except Exception as e :
48+ raise e
49+ return pods
50+
51+
52+ def get_mission (mission : str ) -> list [V1Pod ]:
4753 pods = get_pods ()
48- crew = []
49- for pod in pods . items :
54+ crew : list [ V1Pod ] = []
55+ for pod in pods :
5056 if "mission" in pod .metadata .labels and pod .metadata .labels ["mission" ] == mission :
5157 crew .append (pod )
5258 return crew
You can’t perform that action at this time.
0 commit comments