Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup helm when running the clean command #194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/App/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ open StellarNetworkCfg
open StellarMission
open StellarMissionContext
open StellarSupercluster
open MissionHistoryPubnetParallelCatchupV2

open System.Threading

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -556,6 +559,7 @@ let main argv =
let nCfg = MakeNetworkCfg ctx [] None
use formation = kube.MakeEmptyFormation nCfg
formation.CleanNamespace()
localCleanup ()
0

| :? MissionOptions as mission ->
Expand Down
13 changes: 7 additions & 6 deletions src/FSLibrary/MissionHistoryPubnetParallelCatchupV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -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 ()
Loading