Skip to content

Commit

Permalink
[SPVR-122] Node should be up instead of down after restarting eru-age…
Browse files Browse the repository at this point in the history
…nt for node (#81)

* update dependency

* remove selfmon local cache
  • Loading branch information
DuodenumL authored Oct 25, 2021
1 parent 88c1fd7 commit 3b5d92d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
12 changes: 0 additions & 12 deletions selfmon/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package selfmon
import (
"context"
"io"
"math/rand"
"time"

"github.com/projecteru2/agent/types"
Expand Down Expand Up @@ -91,14 +90,6 @@ func (m *Selfmon) dealNodeStatusMessage(ctx context.Context, message *types.Node
return
}

lastValue, ok := m.status.Get(message.Nodename)
if ok {
last, o := lastValue.(bool)
if o && last == message.Alive {
return
}
}

// TODO maybe we need a distributed lock to control concurrency
var err error
utils.WithTimeout(ctx, m.config.GlobalConnectionTimeout, func(ctx context.Context) {
Expand All @@ -107,10 +98,7 @@ func (m *Selfmon) dealNodeStatusMessage(ctx context.Context, message *types.Node

if err != nil {
log.Errorf("[selfmon] set node %s failed %v", message.Nodename, err)
m.status.Delete(message.Nodename)
return
}
log.Debugf("[selfmon] set node %s as alive: %v", message.Nodename, message.Alive)

m.status.Set(message.Nodename, message.Alive, time.Duration(300+rand.Intn(100))*time.Second) // nolint
}
1 change: 0 additions & 1 deletion selfmon/selfmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type Selfmon struct {
func New(ctx context.Context, config *types.Config) (mon *Selfmon, err error) {
mon = &Selfmon{}
mon.config = config
mon.status = cache.New(time.Minute*5, time.Minute*15)
mon.exit.C = make(chan struct{}, 1)
mon.id = time.Now().UnixNano() / 1000 % 10000

Expand Down

0 comments on commit 3b5d92d

Please sign in to comment.