From 7f0f109a12aa804f0560c55872d22630a1590a1c Mon Sep 17 00:00:00 2001 From: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> Date: Mon, 29 Apr 2024 05:03:33 +0200 Subject: [PATCH] ci: add only start with new binary flag to upgrade assure --- scripts/upgrade-assure/README.md | 16 ++++++++++++ scripts/upgrade-assure/get-flags.go | 31 +++++++++++++++--------- scripts/upgrade-assure/upgrade-assure.go | 14 ++++++++++- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/scripts/upgrade-assure/README.md b/scripts/upgrade-assure/README.md index 94c848a09..370a6b52c 100644 --- a/scripts/upgrade-assure/README.md +++ b/scripts/upgrade-assure/README.md @@ -107,6 +107,14 @@ Execute the final upgrade command to complete the upgrade process: go run ./scripts/upgrade-assure/... /tmp/snapshot.tar.lz4 /tmp/elysd-v0.30.0 ~/go/bin/elysd --skip-snapshot --skip-chain-init ``` +### Step 9: Start the Nodes manually (optional) + +If something went wrong while you were starting the node at step 8, you can start the nodes manually with the new binary by using the following command: + +```bash +go run ./scripts/upgrade-assure/... /tmp/snapshot.tar.lz4 /tmp/elysd-v0.30.0 ~/go/bin/elysd --only-start-with-new-binary +``` + ## Testnet Snapshots Usage **Snapshot Sources and Installation Procedures:** @@ -140,3 +148,11 @@ go run ./scripts/upgrade-assure/... /tmp/snapshot.tar.lz4 /tmp/elysd-v0.30.0 ~/g --timeout-wait-for-node=600 # Time in seconds --timeout-next-block=15 # Time in minutes ``` + +**My nodes crashed after the upgrade. What should I do?** + +Run the following command to start the nodes manually: + +```bash +go run ./scripts/upgrade-assure/... /tmp/snapshot.tar.lz4 ~/go/bin/elysd ~/go/bin/elysd --only-start-with-new-binary +``` diff --git a/scripts/upgrade-assure/get-flags.go b/scripts/upgrade-assure/get-flags.go index f0208ed34..0c35e04ef 100644 --- a/scripts/upgrade-assure/get-flags.go +++ b/scripts/upgrade-assure/get-flags.go @@ -9,18 +9,19 @@ import ( const ( // global - flagSkipSnapshot = "skip-snapshot" - flagSkipChainInit = "skip-chain-init" - flagSkipNodeStart = "skip-node-start" - flagSkipProposal = "skip-proposal" - flagSkipBinary = "skip-binary" - flagChainId = "chain-id" - flagKeyringBackend = "keyring-backend" - flagGenesisFilePath = "genesis-file-path" - flagBroadcastMode = "broadcast-mode" - flagDbEngine = "db-engine" - - //Timeout + flagOnlyStartWithNewBinary = "only-start-with-new-binary" + flagSkipSnapshot = "skip-snapshot" + flagSkipChainInit = "skip-chain-init" + flagSkipNodeStart = "skip-node-start" + flagSkipProposal = "skip-proposal" + flagSkipBinary = "skip-binary" + flagChainId = "chain-id" + flagKeyringBackend = "keyring-backend" + flagGenesisFilePath = "genesis-file-path" + flagBroadcastMode = "broadcast-mode" + flagDbEngine = "db-engine" + + // timeout flagTimeOutToWaitForService = "timeout-wait-for-node" flagTimeOutNextBlock = "timeout-next-block" @@ -51,6 +52,7 @@ const ( func getFlags(cmd *cobra.Command) ( // global + onlyStartWithNewBinaries bool, skipSnapshot bool, skipChainInit bool, skipNodeStart bool, @@ -91,6 +93,11 @@ func getFlags(cmd *cobra.Command) ( api2 string, ) { // global + onlyStartWithNewBinaries, _ = cmd.Flags().GetBool(flagOnlyStartWithNewBinary) + if onlyStartWithNewBinaries { + log.Printf(ColorYellow + "only starting with new binaries, skipping all other steps") + } + skipSnapshot, _ = cmd.Flags().GetBool(flagSkipSnapshot) if skipSnapshot { log.Printf(ColorYellow + "skipping snapshot retrieval") diff --git a/scripts/upgrade-assure/upgrade-assure.go b/scripts/upgrade-assure/upgrade-assure.go index 63fb7b1b8..e569ba3e5 100644 --- a/scripts/upgrade-assure/upgrade-assure.go +++ b/scripts/upgrade-assure/upgrade-assure.go @@ -18,7 +18,7 @@ func main() { Run: func(cmd *cobra.Command, args []string) { snapshotUrl, oldBinaryUrl, newBinaryUrl := getArgs(args) // global flags - skipSnapshot, skipChainInit, skipNodeStart, skipProposal, skipBinary, chainId, keyringBackend, genesisFilePath, broadcastMode, dbEngine, + onlyStartWithNewBinary, skipSnapshot, skipChainInit, skipNodeStart, skipProposal, skipBinary, chainId, keyringBackend, genesisFilePath, broadcastMode, dbEngine, // timeouts timeOutToWaitForService, timeOutToWaitForNextBlock, // node 1 flags @@ -48,6 +48,17 @@ func main() { // print new binary path and version log.Printf(ColorGreen+"New binary path: %v and version: %v", newBinaryPath, newVersion) + // only start with new binary, skip everything else + if onlyStartWithNewBinary { + // start new binary + newBinaryCmd := start(newBinaryPath, homePath, rpc, p2p, pprof, api, moniker, "\033[32m", "\033[31m") + newBinaryCmd2 := start(newBinaryPath, homePath2, rpc2, p2p2, pprof2, api2, moniker2, "\033[32m", "\033[31m") + + // listen for signals + listenForSignals(newBinaryCmd, newBinaryCmd2) + return + } + if !skipSnapshot { // remove home path removeHome(homePath) @@ -210,6 +221,7 @@ func main() { homeEnv, _ := os.LookupEnv("HOME") // global flags + rootCmd.PersistentFlags().Bool(flagOnlyStartWithNewBinary, false, "only start with new binary") rootCmd.PersistentFlags().Bool(flagSkipSnapshot, false, "skip snapshot retrieval") rootCmd.PersistentFlags().Bool(flagSkipChainInit, false, "skip chain init") rootCmd.PersistentFlags().Bool(flagSkipNodeStart, false, "skip node start")