Skip to content

Commit 04be184

Browse files
committed
_logs: do not rely on container name
Instead rely on the position of the container. Position Rule: we get logs from the first container as reported by V1Pod's spec.container metadata.
1 parent e84416b commit 04be184

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/warnet/control.py

Lines changed: 8 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,
@@ -289,7 +290,13 @@ def _logs(pod_name: str, follow: bool):
289290
else:
290291
return # cancelled by user
291292

292-
container_name = "bitcoincore" if pod_name.startswith("tank") else None
293+
try:
294+
pod = get_pod(pod_name)
295+
container_names = [container.name for container in pod.spec.containers]
296+
container_name = container_names[0]
297+
except Exception as e:
298+
print(f"Could not determine primary container: {e}")
299+
container_name = None
293300

294301
try:
295302
stream = pod_log(pod_name, container_name=container_name, follow=follow)

0 commit comments

Comments
 (0)