Skip to content

Commit 2bc03f0

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 66209c8 commit 2bc03f0

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
@@ -20,6 +20,7 @@
2020
delete_pod,
2121
get_default_namespace,
2222
get_mission,
23+
get_pod,
2324
get_pods,
2425
pod_log,
2526
snapshot_bitcoin_datadir,
@@ -285,7 +286,13 @@ def _logs(pod_name: str, follow: bool):
285286
else:
286287
return # cancelled by user
287288

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

290297
try:
291298
stream = pod_log(pod_name, container_name=container_name, follow=follow)

0 commit comments

Comments
 (0)