File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,16 @@ def debug_log(tank: str):
6060
6161@bitcoin .command ()
6262@click .argument ("pattern" , type = str , required = True )
63+ @click .option ("--tank" , type = str , required = False , help = "Filter by tank name" )
6364@click .option ("--show-k8s-timestamps" , is_flag = True , default = False , show_default = True )
6465@click .option ("--no-sort" , is_flag = True , default = False , show_default = True )
65- def grep_logs (pattern : str , show_k8s_timestamps : bool , no_sort : bool ):
66+ def grep_logs (pattern : str , tank : str , show_k8s_timestamps : bool , no_sort : bool ):
6667 """
6768 Grep combined bitcoind logs using regex <pattern>
6869 """
6970
7071 try :
71- tanks = get_mission ("tank" )
72+ tanks = get_mission ("tank" , tank )
7273 except MaxRetryError as e :
7374 print (f"{ e } " )
7475 sys .exit (1 )
Original file line number Diff line number Diff line change @@ -30,13 +30,15 @@ def get_pods() -> V1PodList:
3030 return pod_list
3131
3232
33- def get_mission (mission : str ) -> list [V1PodList ]:
34- pods = get_pods ()
35- crew = []
36- for pod in pods .items :
37- if "mission" in pod .metadata .labels and pod .metadata .labels ["mission" ] == mission :
38- crew .append (pod )
39- return crew
33+ def get_mission (mission : str , tank_name : str = None ) -> list :
34+ config .load_kube_config ()
35+ v1 = client .CoreV1Api ()
36+ pods = v1 .list_pod_for_all_namespaces (label_selector = f"mission={ mission } " )
37+
38+ if tank_name :
39+ return [pod for pod in pods .items if pod .metadata .name == tank_name ]
40+ return pods .items
41+
4042
4143
4244def get_pod_exit_status (pod_name ):
You can’t perform that action at this time.
0 commit comments