From 95be1085bc9199bd36ae2722fe1bc57e68d52208 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 20 Jun 2020 16:06:36 +0200 Subject: [PATCH 1/4] Fix downloading of assets in pmctl --- pmctl/main.go | 2 +- pmctl/run.go | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pmctl/main.go b/pmctl/main.go index 0252a799..17818ac5 100644 --- a/pmctl/main.go +++ b/pmctl/main.go @@ -35,7 +35,7 @@ var ( }, Beta: false, DevMode: false, - Online: false, + Online: true, // is disabled later based on command } rootCmd = &cobra.Command{ diff --git a/pmctl/run.go b/pmctl/run.go index c1cad7f8..3c4d49a1 100644 --- a/pmctl/run.go +++ b/pmctl/run.go @@ -107,9 +107,7 @@ func handleRun(cmd *cobra.Command, opts *Options) (err error) { func run(cmd *cobra.Command, opts *Options) (err error) { // set download option - if opts.AllowDownload { - registry.Online = true - } + registry.Online = opts.AllowDownload // parse identifier opts.ShortIdentifier = path.Dir(opts.Identifier) From bb2cbdb5c1ae14ebfe7b9519dd4c39690ce2e311 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 20 Jun 2020 16:06:49 +0200 Subject: [PATCH 2/4] Remove unneeded index in pmctl for now --- pmctl/main.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pmctl/main.go b/pmctl/main.go index 17818ac5..01644c31 100644 --- a/pmctl/main.go +++ b/pmctl/main.go @@ -182,17 +182,12 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) { Beta: false, }) - registry.AddIndex(updater.Index{ - Path: "beta.json", - Stable: false, - Beta: true, - }) - - registry.AddIndex(updater.Index{ - Path: "all/intel/intel.json", - Stable: true, - Beta: false, - }) + // TODO: enable loading beta versions + // registry.AddIndex(updater.Index{ + // Path: "beta.json", + // Stable: false, + // Beta: true, + // }) updateRegistryIndex() } From 79269625672accc65345d7be8102fe28c5decf7c Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 20 Jun 2020 16:08:50 +0200 Subject: [PATCH 3/4] Improve resilience when handling execution errors in pmctl --- pmctl/run.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pmctl/run.go b/pmctl/run.go index 3c4d49a1..7c17a3e4 100644 --- a/pmctl/run.go +++ b/pmctl/run.go @@ -185,8 +185,16 @@ func run(cmd *cobra.Command, opts *Options) (err error) { log.Println("error seems to be permanent, giving up...") return err } + // resilience + time.Sleep(time.Duration(tries) * 2 * time.Second) + if tries >= 2 { + // try updating + updateRegistryIndex() + } log.Println("trying again...") case tryAgain && err == nil: + // reset error count + tries = 0 // upgrade log.Println("restarting by request...") // update index From 054817586a76d2bb94ceef41e4286fdbd7b966d3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 20 Jun 2020 16:18:47 +0200 Subject: [PATCH 4/4] Silence the linter --- pmctl/run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmctl/run.go b/pmctl/run.go index 7c17a3e4..eb5fc367 100644 --- a/pmctl/run.go +++ b/pmctl/run.go @@ -104,7 +104,7 @@ func handleRun(cmd *cobra.Command, opts *Options) (err error) { return } -func run(cmd *cobra.Command, opts *Options) (err error) { +func run(cmd *cobra.Command, opts *Options) (err error) { //nolint:gocognit // set download option registry.Online = opts.AllowDownload