Skip to content

Commit 23a8e21

Browse files
committed
control: fix _logs to look for primary container
Use the logic that the first container listed will be the primary container.
1 parent 8bdbf6a commit 23a8e21

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/warnet/control.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
delete_pod,
2222
get_default_namespace,
2323
get_mission,
24+
get_pod,
2425
get_pods,
2526
pod_log,
2627
snapshot_bitcoin_datadir,
@@ -329,7 +330,15 @@ def _logs(pod_name: str, follow: bool):
329330
return # cancelled by user
330331

331332
try:
332-
stream = pod_log(pod_name, container_name=None, follow=follow)
333+
pod = get_pod(pod_name)
334+
container_names = [container.name for container in pod.spec.containers]
335+
container_name = container_names[0]
336+
except Exception as e:
337+
print(f"Could not determine primary container: {e}")
338+
return
339+
340+
try:
341+
stream = pod_log(pod_name, container_name=container_name, follow=follow)
333342
for line in stream.stream():
334343
print(line.decode("utf-8"), end=None)
335344
except Exception as e:

0 commit comments

Comments
 (0)