26
26
snapshot_bitcoin_datadir ,
27
27
wait_for_pod ,
28
28
)
29
- from .process import run_command , stream_command
29
+ from .process import run_command
30
30
31
31
console = Console ()
32
32
@@ -81,8 +81,8 @@ def stop_scenario(scenario_name):
81
81
"""Stop a single scenario using Helm"""
82
82
# Stop the pod immediately (faster than uninstalling)
83
83
namespace = get_default_namespace ()
84
- cmd = f"kubectl -- namespace { namespace } delete pod { scenario_name } --grace-period=0 -- force"
85
- if stream_command ( cmd ) :
84
+ resp = delete_pod ( scenario_name , namespace , grace_period = 0 , force = True )
85
+ if resp . status == "Success" :
86
86
console .print (f"[bold green]Successfully stopped scenario: { scenario_name } [/bold green]" )
87
87
else :
88
88
console .print (f"[bold red]Failed to stop scenario: { scenario_name } [/bold red]" )
@@ -117,11 +117,6 @@ def uninstall_release(namespace, release_name):
117
117
subprocess .Popen (cmd , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
118
118
return f"Initiated uninstall for: { release_name } in namespace { namespace } "
119
119
120
- def delete_pod (pod_name , namespace ):
121
- cmd = f"kubectl delete pod --ignore-not-found=true { pod_name } -n { namespace } --grace-period=0 --force"
122
- subprocess .Popen (cmd , shell = True , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
123
- return f"Initiated deletion of pod: { pod_name } in namespace { namespace } "
124
-
125
120
with ThreadPoolExecutor (max_workers = 10 ) as executor :
126
121
futures = []
127
122
@@ -137,7 +132,16 @@ def delete_pod(pod_name, namespace):
137
132
# Delete remaining pods
138
133
pods = get_pods ()
139
134
for pod in pods .items :
140
- futures .append (executor .submit (delete_pod , pod .metadata .name , pod .metadata .namespace ))
135
+ futures .append (
136
+ executor .submit (
137
+ delete_pod ,
138
+ pod .metadata .name ,
139
+ pod .metadata .namespace ,
140
+ grace_period = 0 ,
141
+ force = True ,
142
+ ignore_not_found = True ,
143
+ )
144
+ )
141
145
142
146
# Wait for all tasks to complete and print results
143
147
for future in as_completed (futures ):
0 commit comments