From 2fbed339ed1562ab247a46d4f192df2eb96f976f Mon Sep 17 00:00:00 2001 From: Siddharth Suresh Date: Thu, 15 Aug 2024 15:14:15 -0700 Subject: [PATCH] Cleanup helm when running the clean command --- src/App/Program.fs | 4 ++++ .../MissionHistoryPubnetParallelCatchupV2.fs | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/App/Program.fs b/src/App/Program.fs index 2f77cff0..521e924e 100644 --- a/src/App/Program.fs +++ b/src/App/Program.fs @@ -14,6 +14,7 @@ open StellarNetworkCfg open StellarMission open StellarMissionContext open StellarSupercluster +open MissionHistoryPubnetParallelCatchupV2 open System.Threading @@ -441,6 +442,8 @@ type MissionOptions Required = false)>] member self.NumRuns = numRuns +let localCleanup () = cleanupParallelCatchupV2 () + let splitLabel (lab: string) : (string * string option) = match lab.Split ':' with | [| x |] -> (x, None) @@ -556,6 +559,7 @@ let main argv = let nCfg = MakeNetworkCfg ctx [] None use formation = kube.MakeEmptyFormation nCfg formation.CleanNamespace() + localCleanup () 0 | :? MissionOptions as mission -> diff --git a/src/FSLibrary/MissionHistoryPubnetParallelCatchupV2.fs b/src/FSLibrary/MissionHistoryPubnetParallelCatchupV2.fs index 5c02bfed..cc08cb16 100644 --- a/src/FSLibrary/MissionHistoryPubnetParallelCatchupV2.fs +++ b/src/FSLibrary/MissionHistoryPubnetParallelCatchupV2.fs @@ -94,21 +94,22 @@ let installProject (context: MissionContext) = | _ -> () // Cleanup on exit -let cleanup () = +let cleanupParallelCatchupV2 () = if toPerformCleanup then toPerformCleanup <- false LogInfo "Cleaning up resources..." runCommand [| "helm" "uninstall" - helmReleaseName |] + helmReleaseName + "--ignore-not-found" |] |> ignore -System.AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> cleanup ()) +System.AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> cleanupParallelCatchupV2 ()) Console.CancelKeyPress.Add (fun _ -> - cleanup () + cleanupParallelCatchupV2 () Environment.Exit(0)) let getJobMonitorStatus (endPoint: String) = @@ -194,7 +195,7 @@ let historyPubnetParallelCatchupV2 (context: MissionContext) = timeoutLeft <- timeoutLeft - jobMonitorStatusCheckIntervalSecs if timeoutLeft <= 0 then failwith "job monitor not reachable" with ex -> - cleanup () + cleanupParallelCatchupV2 () raise ex - cleanup () + cleanupParallelCatchupV2 ()