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