@@ -19,6 +19,9 @@ pub enum DecommissionCommands {
1919
2020 /// Cancel decommissioning a pool
2121 Cancel ( CancelArgs ) ,
22+
23+ /// Clear failed or canceled decommissioning metadata for a pool
24+ Clear ( ClearArgs ) ,
2225}
2326
2427#[ derive( clap:: Args , Debug ) ]
@@ -60,6 +63,19 @@ pub struct CancelArgs {
6063 pub by_id : bool ,
6164}
6265
66+ #[ derive( clap:: Args , Debug ) ]
67+ pub struct ClearArgs {
68+ /// Alias name of the server
69+ pub alias : String ,
70+
71+ /// Pool command line, or zero-based pool ID with --by-id
72+ pub pool : String ,
73+
74+ /// Interpret POOL as a zero-based pool ID
75+ #[ arg( long) ]
76+ pub by_id : bool ,
77+ }
78+
6379#[ derive( Serialize ) ]
6480struct DecommissionOperationOutput {
6581 success : bool ,
@@ -78,6 +94,7 @@ pub async fn execute(cmd: DecommissionCommands, formatter: &Formatter) -> ExitCo
7894 DecommissionCommands :: Start ( args) => execute_start ( args, formatter) . await ,
7995 DecommissionCommands :: Status ( args) => execute_status ( args, formatter) . await ,
8096 DecommissionCommands :: Cancel ( args) => execute_cancel ( args, formatter) . await ,
97+ DecommissionCommands :: Clear ( args) => execute_clear ( args, formatter) . await ,
8198 }
8299}
83100
@@ -191,3 +208,37 @@ async fn execute_cancel(args: CancelArgs, formatter: &Formatter) -> ExitCode {
191208 }
192209 }
193210}
211+
212+ async fn execute_clear ( args : ClearArgs , formatter : & Formatter ) -> ExitCode {
213+ let client = match get_admin_client ( & args. alias , formatter) {
214+ Ok ( c) => c,
215+ Err ( code) => return code,
216+ } ;
217+
218+ let target = PoolTarget {
219+ pool : args. pool ,
220+ by_id : args. by_id ,
221+ } ;
222+
223+ match client. decommission_clear ( target. clone ( ) ) . await {
224+ Ok ( ( ) ) => {
225+ if formatter. is_json ( ) {
226+ formatter. json ( & DecommissionOperationOutput {
227+ success : true ,
228+ message : "Decommission cleared successfully" . to_string ( ) ,
229+ pool : target. pool ,
230+ } ) ;
231+ } else {
232+ formatter. success ( & format ! (
233+ "Decommission cleared successfully for `{}`." ,
234+ target. pool
235+ ) ) ;
236+ }
237+ ExitCode :: Success
238+ }
239+ Err ( e) => {
240+ formatter. error ( & format ! ( "Failed to clear decommission: {e}" ) ) ;
241+ ExitCode :: GeneralError
242+ }
243+ }
244+ }
0 commit comments