Skip to content

Commit

Permalink
enable bitcoin grep-logs rpc to filter logs by tank name
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed Sep 10, 2024
1 parent 8f0a34d commit 3306f28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/warnet/bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ def debug_log(tank: str):

@bitcoin.command()
@click.argument("pattern", type=str, required=True)
@click.option("--tank", type=str, required=False, help="Filter by tank name")
@click.option("--show-k8s-timestamps", is_flag=True, default=False, show_default=True)
@click.option("--no-sort", is_flag=True, default=False, show_default=True)
def grep_logs(pattern: str, show_k8s_timestamps: bool, no_sort: bool):
def grep_logs(pattern: str, tank:str, show_k8s_timestamps: bool, no_sort: bool):
"""
Grep combined bitcoind logs using regex <pattern>
"""

try:
tanks = get_mission("tank")
tanks = get_mission("tank", tank)
except MaxRetryError as e:
print(f"{e}")
sys.exit(1)
Expand Down
16 changes: 9 additions & 7 deletions src/warnet/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def get_pods() -> V1PodList:
return pod_list


def get_mission(mission: str) -> list[V1PodList]:
pods = get_pods()
crew = []
for pod in pods.items:
if "mission" in pod.metadata.labels and pod.metadata.labels["mission"] == mission:
crew.append(pod)
return crew
def get_mission(mission: str, tank_name: str = None) -> list:
config.load_kube_config()
v1 = client.CoreV1Api()
pods = v1.list_pod_for_all_namespaces(label_selector=f"mission={mission}")

if tank_name:
return [pod for pod in pods.items if pod.metadata.name == tank_name]
return pods.items



def get_pod_exit_status(pod_name):
Expand Down

0 comments on commit 3306f28

Please sign in to comment.