Skip to content

Commit

Permalink
Fix bug: enforce node exe install if file is absent
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Litvinov <jnashicq@gmail.com>
  • Loading branch information
Zensey committed Apr 19, 2024
1 parent 98b3dd0 commit 8bd5895
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {

Expand Down
10 changes: 6 additions & 4 deletions controller/native/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -83,6 +85,7 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b
doRefresh := cfg.NodeExeVersion == "" || cfg.NodeExeLatestTag == "" ||
cfg.TimeToCheckUpgrade() ||
refreshVersionCache ||
fileAbsent ||
doUpgrade

if !doRefresh {
Expand All @@ -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)
Expand All @@ -124,8 +127,7 @@ func (c *Native_) CheckAndUpgradeNodeExe_(refreshVersionCache, doUpgrade bool) b

return true
}

return doUpgrade_
return hasUpdate()
}

// returns: will exit
Expand Down

0 comments on commit 8bd5895

Please sign in to comment.