Skip to content

Commit 3026c98

Browse files
committed
add binary to status
1 parent 6c18672 commit 3026c98

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

resources/charts/binary-runner/templates/pod.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ spec:
1212
volumes:
1313
- name: shared-data
1414
emptyDir: {}
15-
initContainers:
16-
- name: {{ .Values.pod.name }}-receiver
15+
containers:
16+
- name: {{ .Values.pod.name }}-runner
1717
image: alpine
1818
command: ["/bin/sh", "-c"]
1919
args:
@@ -23,15 +23,6 @@ spec:
2323
sleep 1
2424
done
2525
echo "Binary found!"
26-
volumeMounts:
27-
- name: shared-data
28-
mountPath: /data
29-
containers:
30-
- name: {{ .Values.pod.name }}-runner
31-
image: alpine
32-
command: ["/bin/sh", "-c"]
33-
args:
34-
- |
3526
chmod +x /data/binary
3627
/data/binary
3728
exit 0

src/warnet/control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ def run_binary(file: str, additional_args: tuple[str]):
310310
]
311311
subprocess.run(wait_command, check=True)
312312

313-
# Copy the binary into the init container using k8s
314-
command = f"kubectl cp {file_path} -n {namespace} {name}:/data/binary -c {name}-receiver"
313+
# Copy the binary into the container using k8s
314+
command = f"kubectl cp {file_path} -n {namespace} {name}:/data/binary -c {name}-runner"
315315
subprocess.run(shlex.split(command))
316316

317317
if result.returncode == 0:

src/warnet/status.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def status():
1515

1616
tanks = _get_tank_status()
1717
scenarios = _get_active_scenarios()
18+
binaries = _get_active_binaries()
1819

1920
# Create a unified table
2021
table = Table(title="Warnet Status", show_header=True, header_style="bold magenta")
@@ -37,6 +38,17 @@ def status():
3738
else:
3839
table.add_row("Scenario", "No active scenarios", "")
3940

41+
# Add a separator if there are both tanks or scenarios and binaries
42+
if (tanks or scenarios) and binaries:
43+
table.add_row("", "", "")
44+
45+
# Add binaries to the table
46+
if binaries:
47+
for binary in binaries:
48+
table.add_row("Binary", binary["name"], binary["status"])
49+
else:
50+
table.add_row("Binaries", "No active binaries", "")
51+
4052
# Create a panel to wrap the table
4153
panel = Panel(
4254
table,
@@ -53,6 +65,7 @@ def status():
5365
summary = Text()
5466
summary.append(f"\nTotal Tanks: {len(tanks)}", style="bold cyan")
5567
summary.append(f" | Active Scenarios: {len(scenarios)}", style="bold green")
68+
summary.append(f" | Active Binaries: {len(binaries)}", style="bold red")
5669
console.print(summary)
5770
_connected(end="\r")
5871

@@ -65,3 +78,8 @@ def _get_tank_status():
6578
def _get_active_scenarios():
6679
commanders = get_mission("commander")
6780
return [{"name": c.metadata.name, "status": c.status.phase.lower()} for c in commanders]
81+
82+
83+
def _get_active_binaries():
84+
binaries = get_mission("binary")
85+
return [{"name": b.metadata.name, "status": b.status.phase.lower()} for b in binaries]

0 commit comments

Comments
 (0)