@@ -190,21 +190,26 @@ def get_messages(tank_a: str, tank_b: str, chain: str):
190
190
"""
191
191
Fetch messages from the message capture files
192
192
"""
193
+ sclient = get_static_client ()
194
+
193
195
subdir = "" if chain == "main" else f"{ chain } /"
194
196
base_dir = f"/root/.bitcoin/{ subdir } message_capture"
195
197
196
198
# Get the IP of node_b
197
- cmd = f"kubectl get pod { tank_b } -o jsonpath='{{.status.podIP}}'"
198
- tank_b_ip = run_command ( cmd ). strip ()
199
+ tank_b_pod : V1Pod = sclient . read_namespaced_pod ( name = tank_b , namespace = get_default_namespace ())
200
+ tank_b_ip = tank_b_pod . status . pod_ip
199
201
200
202
# Get the service IP of node_b
201
- cmd = f"kubectl get service { tank_b } -o jsonpath='{{.spec.clusterIP}}'"
202
- tank_b_service_ip = run_command (cmd ).strip ()
203
+ tank_b_service : V1Service = sclient .read_namespaced_service (
204
+ name = tank_b , namespace = get_default_namespace ()
205
+ )
206
+ tank_b_service_ip = tank_b_service .spec .cluster_ip
203
207
204
208
# List directories in the message capture folder
205
- cmd = f"kubectl exec { tank_a } -- ls { base_dir } "
206
209
207
- dirs = run_command (cmd ).splitlines ()
210
+ resp = kexec (tank_a , get_default_namespace (), ["ls" , base_dir ])
211
+
212
+ dirs = resp .splitlines ()
208
213
209
214
messages = []
210
215
@@ -213,18 +218,15 @@ def get_messages(tank_a: str, tank_b: str, chain: str):
213
218
for file , outbound in [["msgs_recv.dat" , False ], ["msgs_sent.dat" , True ]]:
214
219
file_path = f"{ base_dir } /{ dir_name } /{ file } "
215
220
# Fetch the file contents from the container
216
- cmd = f"kubectl exec { tank_a } -- cat { file_path } "
217
- import subprocess
218
-
219
- blob = subprocess .run (
220
- cmd , shell = True , capture_output = True , executable = "bash"
221
- ).stdout
222
221
222
+ resp = kexec (tank_a , get_default_namespace (), ["base64" , file_path ])
223
+ resp_bytes = base64 .b64decode (resp )
223
224
# Parse the blob
224
- json = parse_raw_messages (blob , outbound )
225
+ json = parse_raw_messages (resp_bytes , outbound )
225
226
messages = messages + json
226
227
227
228
messages .sort (key = lambda x : x ["time" ])
229
+
228
230
return messages
229
231
230
232
0 commit comments