Skip to content
Snippets Groups Projects
Commit c59f39b5 authored by Jake Taylor's avatar Jake Taylor
Browse files

prevent hostpool from adding stale nodes

parent 48e1227b
No related branches found
No related tags found
3 merge requests!53Release,!24Lesure/offline nodes,!15prevent hostpool from adding stale nodes
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at // This file was generated by robots at
// 2021-07-27 14:13:01.428348 -0500 CDT m=+0.036560333 // 2021-08-31 11:45:21.187922 -0500 CDT m=+0.035702296
package api package api
const GITVERSION = `758d1e91 Merge branch 'protoMainNet' into 'release'` const GITVERSION = `48e1227b Merge branch 'hotfix/NoHostCooldown' into 'release'`
const SEMVER = "2.8.0" const SEMVER = "2.8.0"
const DEPENDENCIES = `module gitlab.com/elixxir/client const DEPENDENCIES = `module gitlab.com/elixxir/client
...@@ -24,13 +24,13 @@ require ( ...@@ -24,13 +24,13 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/viper v1.7.1 github.com/spf13/viper v1.7.1
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20210714201329-5efcbdfac3ca gitlab.com/elixxir/comms v0.0.4-0.20210823164208-0e219b367d23
gitlab.com/elixxir/crypto v0.0.7-0.20210714201100-45fb778a00fb gitlab.com/elixxir/crypto v0.0.7-0.20210803232056-ba3ff44cc618
gitlab.com/elixxir/ekv v0.1.5 gitlab.com/elixxir/ekv v0.1.5
gitlab.com/elixxir/primitives v0.0.3-0.20210714200942-a908050c230c gitlab.com/elixxir/primitives v0.0.3-0.20210803231939-7b924f78eaac
gitlab.com/xx_network/comms v0.0.4-0.20210714165756-8e3b40d71db1 gitlab.com/xx_network/comms v0.0.4-0.20210813170223-ab758f0bbec5
gitlab.com/xx_network/crypto v0.0.5-0.20210714165656-1ed326047ba9 gitlab.com/xx_network/crypto v0.0.5-0.20210803231814-b18476a2257c
gitlab.com/xx_network/primitives v0.0.4-0.20210727175935-dd746a0d73de gitlab.com/xx_network/primitives v0.0.4-0.20210823190857-5d07df2f3a5f
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 golang.org/x/net v0.0.0-20210525063256-abc453219eb5
google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect
......
...@@ -23,7 +23,7 @@ require ( ...@@ -23,7 +23,7 @@ require (
gitlab.com/elixxir/primitives v0.0.3-0.20210803231939-7b924f78eaac gitlab.com/elixxir/primitives v0.0.3-0.20210803231939-7b924f78eaac
gitlab.com/xx_network/comms v0.0.4-0.20210813170223-ab758f0bbec5 gitlab.com/xx_network/comms v0.0.4-0.20210813170223-ab758f0bbec5
gitlab.com/xx_network/crypto v0.0.5-0.20210803231814-b18476a2257c gitlab.com/xx_network/crypto v0.0.5-0.20210803231814-b18476a2257c
gitlab.com/xx_network/primitives v0.0.4-0.20210803222745-e898d5e546e9 gitlab.com/xx_network/primitives v0.0.4-0.20210823190857-5d07df2f3a5f
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 golang.org/x/net v0.0.0-20210525063256-abc453219eb5
google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect
......
...@@ -275,8 +275,9 @@ gitlab.com/xx_network/crypto v0.0.5-0.20210803231814-b18476a2257c/go.mod h1:e/5M ...@@ -275,8 +275,9 @@ gitlab.com/xx_network/crypto v0.0.5-0.20210803231814-b18476a2257c/go.mod h1:e/5M
gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA= gitlab.com/xx_network/primitives v0.0.0-20200803231956-9b192c57ea7c/go.mod h1:wtdCMr7DPePz9qwctNoAUzZtbOSHSedcK++3Df3psjA=
gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug= gitlab.com/xx_network/primitives v0.0.0-20200804183002-f99f7a7284da/go.mod h1:OK9xevzWCaPO7b1wiluVJGk7R5ZsuC7pHY5hteZFQug=
gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc= gitlab.com/xx_network/primitives v0.0.2/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc=
gitlab.com/xx_network/primitives v0.0.4-0.20210803222745-e898d5e546e9 h1:YP9xJXZLdSlSoxehK1oDyfUMUY5bNuSpWYXex4x13rc=
gitlab.com/xx_network/primitives v0.0.4-0.20210803222745-e898d5e546e9/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= gitlab.com/xx_network/primitives v0.0.4-0.20210803222745-e898d5e546e9/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/primitives v0.0.4-0.20210823190857-5d07df2f3a5f h1:xw/Mfl8UQXn+P3njaSKv1B6hX+Qe8LIfY7x4Q/Zjgm8=
gitlab.com/xx_network/primitives v0.0.4-0.20210823190857-5d07df2f3a5f/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE=
gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5 h1:FY+4Rh1Q2rgLyv10aKJjhWApuKRCR/054XhreudfAvw= gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5 h1:FY+4Rh1Q2rgLyv10aKJjhWApuKRCR/054XhreudfAvw=
gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= gitlab.com/xx_network/ring v0.0.3-0.20210527191221-ce3f170aabd5/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
......
...@@ -281,7 +281,7 @@ func (h *HostPool) checkReplace(hostId *id.ID, hostErr error) (bool, error) { ...@@ -281,7 +281,7 @@ func (h *HostPool) checkReplace(hostId *id.ID, hostErr error) (bool, error) {
if hostErr != nil { if hostErr != nil {
for _, errString := range errorsList { for _, errString := range errorsList {
if strings.Contains(hostErr.Error(), errString) { if strings.Contains(hostErr.Error(), errString) {
// Host needs replaced, flag and continue // Host needs to be replaced, flag and continue
doReplace = true doReplace = true
break break
} }
...@@ -319,6 +319,15 @@ func (h *HostPool) forceReplace(oldPoolIndex uint32) error { ...@@ -319,6 +319,15 @@ func (h *HostPool) forceReplace(oldPoolIndex uint32) error {
return errors.WithMessage(err, "failed to get Gateway for pruning") return errors.WithMessage(err, "failed to get Gateway for pruning")
} }
// Verify the Gateway's Node is not Stale before adding to HostPool
nodeId := gwId.DeepCopy()
nodeId.SetType(id.Node)
nodeNdfIdx := h.ndfMap[*nodeId]
isNodeStale := h.ndf.Nodes[nodeNdfIdx].Status != ndf.Stale
if isNodeStale {
continue
}
// Verify the new GwId is not already in the hostMap // Verify the new GwId is not already in the hostMap
if _, ok := h.hostMap[*gwId]; !ok { if _, ok := h.hostMap[*gwId]; !ok {
// If it is a new GwId, replace the old Host with the new Host // If it is a new GwId, replace the old Host with the new Host
...@@ -434,7 +443,7 @@ func convertNdfToMap(ndf *ndf.NetworkDefinition) (map[id.ID]int, error) { ...@@ -434,7 +443,7 @@ func convertNdfToMap(ndf *ndf.NetworkDefinition) (map[id.ID]int, error) {
return result, nil return result, nil
} }
// Process gateway Id's into set // Process gateway Ids into set
for i := range ndf.Gateways { for i := range ndf.Gateways {
gw := ndf.Gateways[i] gw := ndf.Gateways[i]
gwId, err := id.Unmarshal(gw.ID) gwId, err := id.Unmarshal(gw.ID)
...@@ -444,6 +453,16 @@ func convertNdfToMap(ndf *ndf.NetworkDefinition) (map[id.ID]int, error) { ...@@ -444,6 +453,16 @@ func convertNdfToMap(ndf *ndf.NetworkDefinition) (map[id.ID]int, error) {
result[*gwId] = i result[*gwId] = i
} }
// Process node Ids into set
for i := range ndf.Nodes {
node := ndf.Nodes[i]
nodeId, err := id.Unmarshal(node.ID)
if err != nil {
return nil, err
}
result[*nodeId] = i
}
return result, nil return result, nil
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment