Skip to content

Commit 8190180

Browse files
authored
Merge pull request #492 from willcl-ark/fix-dup-del-on-down
2 parents 1061fc8 + e577442 commit 8190180

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/warnet/control.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,12 @@ def list_active_scenarios():
112112
@click.command()
113113
def down():
114114
"""Bring down a running warnet"""
115-
console.print("[bold yellow]Bringing down the warnet...[/bold yellow]")
116-
117-
# Delete warnet-logging namespace
118-
if delete_namespace("warnet-logging"):
119-
console.print("[green]Warnet logging deleted[/green]")
120-
else:
121-
console.print("[red]Warnet logging NOT deleted[/red]")
115+
with console.status("[bold yellow]Bringing down the warnet...[/bold yellow]"):
116+
# Delete warnet-logging namespace
117+
if delete_namespace("warnet-logging"):
118+
console.print("[green]Warnet logging deleted[/green]")
119+
else:
120+
console.print("[red]Warnet logging NOT deleted[/red]")
122121

123122
# Uninstall tanks
124123
tanks = get_mission("tank")
@@ -134,7 +133,7 @@ def down():
134133
pods = get_pods()
135134
with console.status("[yellow]Cleaning up remaining pods...[/yellow]"):
136135
for pod in pods.items:
137-
cmd = f"kubectl delete pod {pod.metadata.name}"
136+
cmd = f"kubectl delete pod --ignore-not-found=true {pod.metadata.name}"
138137
if stream_command(cmd):
139138
console.print(f"[green]Deleted pod: {pod.metadata.name}[/green]")
140139
else:

src/warnet/process.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def run_command(command: str) -> str:
1010
return result.stdout
1111

1212

13-
def stream_command(command: str, env=None) -> bool:
13+
def stream_command(command: str) -> bool:
1414
process = subprocess.Popen(
1515
["/bin/bash", "-c", command],
1616
stdout=subprocess.PIPE,
@@ -27,6 +27,5 @@ def stream_command(command: str, env=None) -> bool:
2727
return_code = process.wait()
2828

2929
if return_code != 0:
30-
print(f"Command failed with return code {return_code}")
31-
return False
30+
raise Exception(process.stderr)
3231
return True

0 commit comments

Comments
 (0)