From 8bd589529bbc9a158882468640e1580afc85072d Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 19 Apr 2024 16:32:49 +0300 Subject: [PATCH] Fix bug: enforce node exe install if file is absent Signed-off-by: Anton Litvinov --- controller/controller.go | 8 +++----- controller/native/install.go | 10 ++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index 0dc0fef..628ef17 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -129,10 +129,9 @@ func (c *Controller) startBackendControl() { } // now we have runtime (docker) running - hasUpdates := false - if !c.waitForShutdownReady { - hasUpdates = c.runner.CheckCurrentVersionAndUpgrades(false) - } +// if !c.waitForShutdownReady { +// } + hasUpdates := c.runner.CheckCurrentVersionAndUpgrades(false) if !c.runner.IsRunning() { if c.model.Config.AutoUpgrade && hasUpdates { @@ -141,7 +140,6 @@ func (c *Controller) startBackendControl() { } c.runner.StartContainer() - c.lg.Println("startNode >", c.model.Config.AutoUpgrade, hasUpdates) if c.model.Config.AutoUpgrade && hasUpdates { diff --git a/controller/native/install.go b/controller/native/install.go index 879897a..ed6773f 100644 --- a/controller/native/install.go +++ b/controller/native/install.go @@ -53,10 +53,12 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b exename := getNodeProcessName() fullpath := utils.MakeCanonicalPath(path.Join(c.runner.binpath, exename)) + fileAbsent := false file, err := os.Stat(fullpath) if err != nil { cfg.NodeExeVersion = "" cfg.NodeExeTimestamp = time.Time{} + fileAbsent = true } else { modTime := file.ModTime() if !modTime.Equal(cfg.NodeExeTimestamp) { @@ -83,6 +85,7 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b doRefresh := cfg.NodeExeVersion == "" || cfg.NodeExeLatestTag == "" || cfg.TimeToCheckUpgrade() || refreshVersionCache || + fileAbsent || doUpgrade if !doRefresh { @@ -104,9 +107,9 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b setUi() doUpgrade_ := hasUpdate() && doUpgrade - log.Println("CheckAndUpgradeNodeExe doUpgrade>", doUpgrade_) + log.Println("CheckAndUpgradeNodeExe doUpgrade>", hasUpdate(), doUpgrade_) - if doUpgrade_ { + if doUpgrade_ || fileAbsent { p, _ := utils.IsProcessRunningExt(exename, fullpath) if p != 0 { utils.TerminateProcess(p, 0) @@ -124,8 +127,7 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b return true } - - return doUpgrade_ + return hasUpdate() } // returns: will exit