[#516] node: Send bootstrap request if attributes were updated
Consider following situation: 1. Epoch tick. 2. Update node attributes in the config. 3. Restart node. Because we already sent bootstrap query after (1) and we are still online, new bootstrap query won't be sent. This leads to the node attributes being updated after another epoch. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
0e697266c3
commit
d3a52ec73a
2 changed files with 14 additions and 7 deletions
|
@ -343,8 +343,8 @@ type internals struct {
|
||||||
apiVersion version.Version
|
apiVersion version.Version
|
||||||
healthStatus *atomic.Int32
|
healthStatus *atomic.Int32
|
||||||
// is node under maintenance
|
// is node under maintenance
|
||||||
isMaintenance atomic.Bool
|
isMaintenance atomic.Bool
|
||||||
isOnlineCandidate bool
|
alreadyBootstraped bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// starts node's maintenance.
|
// starts node's maintenance.
|
||||||
|
|
|
@ -227,7 +227,7 @@ func bootstrapNode(c *cfg) {
|
||||||
c.log.Info(logs.FrostFSNodeNodeIsUnderMaintenanceSkipInitialBootstrap)
|
c.log.Info(logs.FrostFSNodeNodeIsUnderMaintenanceSkipInitialBootstrap)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.isOnlineCandidate {
|
if c.alreadyBootstraped {
|
||||||
c.log.Info(logs.NetmapNodeAlreadyInCandidateListOnlineSkipInitialBootstrap)
|
c.log.Info(logs.NetmapNodeAlreadyInCandidateListOnlineSkipInitialBootstrap)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ func initNetmapState(c *cfg) {
|
||||||
fatalOnErrDetails("could not initialize current epoch number", err)
|
fatalOnErrDetails("could not initialize current epoch number", err)
|
||||||
|
|
||||||
var ni *netmapSDK.NodeInfo
|
var ni *netmapSDK.NodeInfo
|
||||||
ni, c.isOnlineCandidate, err = c.netmapInitLocalNodeState(epoch)
|
ni, c.alreadyBootstraped, err = c.netmapInitLocalNodeState(epoch)
|
||||||
fatalOnErrDetails("could not init network state", err)
|
fatalOnErrDetails("could not init network state", err)
|
||||||
|
|
||||||
stateWord := nodeState(ni)
|
stateWord := nodeState(ni)
|
||||||
|
@ -282,6 +282,13 @@ func initNetmapState(c *cfg) {
|
||||||
c.handleLocalNodeInfo(ni)
|
c.handleLocalNodeInfo(ni)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sameNodeInfo(a, b *netmapSDK.NodeInfo) bool {
|
||||||
|
// Suboptimal, but we do this once on the node startup.
|
||||||
|
rawA := a.Marshal()
|
||||||
|
rawB := b.Marshal()
|
||||||
|
return bytes.Equal(rawA, rawB)
|
||||||
|
}
|
||||||
|
|
||||||
func nodeState(ni *netmapSDK.NodeInfo) string {
|
func nodeState(ni *netmapSDK.NodeInfo) string {
|
||||||
if ni != nil {
|
if ni != nil {
|
||||||
switch {
|
switch {
|
||||||
|
@ -303,11 +310,11 @@ func (c *cfg) netmapInitLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
var candidate *netmapSDK.NodeInfo
|
var candidate *netmapSDK.NodeInfo
|
||||||
isOnlineCandidate := false
|
alreadyBootstraped := false
|
||||||
for i := range nmNodes {
|
for i := range nmNodes {
|
||||||
if bytes.Equal(nmNodes[i].PublicKey(), c.binPublicKey) {
|
if bytes.Equal(nmNodes[i].PublicKey(), c.binPublicKey) {
|
||||||
candidate = &nmNodes[i]
|
candidate = &nmNodes[i]
|
||||||
isOnlineCandidate = candidate.IsOnline()
|
alreadyBootstraped = candidate.IsOnline() && sameNodeInfo(&c.cfgNodeInfo.localInfo, candidate)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +337,7 @@ func (c *cfg) netmapInitLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, bool,
|
||||||
zap.String("netmap", nmState),
|
zap.String("netmap", nmState),
|
||||||
zap.String("candidate", candidateState))
|
zap.String("candidate", candidateState))
|
||||||
}
|
}
|
||||||
return candidate, isOnlineCandidate, nil
|
return candidate, alreadyBootstraped, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
|
func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
|
||||||
|
|
Loading…
Reference in a new issue