mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-25 08:34:47 +08:00
Merge pull request #1029 from gravitl/feature_v0.13.0_btr_serv_reset
added initial notification to clients on server startup
This commit is contained in:
commit
1b7efe1ced
4 changed files with 26 additions and 1 deletions
6
main.go
6
main.go
|
@ -119,6 +119,12 @@ func initialize() { // Client Mode Prereq Check
|
||||||
logger.FatalLog(err.Error())
|
logger.FatalLog(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if servercfg.IsMessageQueueBackend() {
|
||||||
|
if err = mq.ServerStartNotify(); err != nil {
|
||||||
|
logger.Log(0, "error occurred when notifying nodes of startup", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
genCerts()
|
genCerts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ const (
|
||||||
TEN_YEARS_IN_SECONDS = 300000000
|
TEN_YEARS_IN_SECONDS = 300000000
|
||||||
// MAX_NAME_LENGTH - max name length of node
|
// MAX_NAME_LENGTH - max name length of node
|
||||||
MAX_NAME_LENGTH = 62
|
MAX_NAME_LENGTH = 62
|
||||||
// == ACTIONS == (can only be set by GRPC)
|
// == ACTIONS == (can only be set by server)
|
||||||
// NODE_UPDATE_KEY - action to update key
|
// NODE_UPDATE_KEY - action to update key
|
||||||
NODE_UPDATE_KEY = "updatekey"
|
NODE_UPDATE_KEY = "updatekey"
|
||||||
// NODE_DELETE - delete node action
|
// NODE_DELETE - delete node action
|
||||||
|
@ -26,6 +26,8 @@ const (
|
||||||
NODE_IS_PENDING = "pending"
|
NODE_IS_PENDING = "pending"
|
||||||
// NODE_NOOP - node no op action
|
// NODE_NOOP - node no op action
|
||||||
NODE_NOOP = "noop"
|
NODE_NOOP = "noop"
|
||||||
|
// NODE_FORCE_UPDATE - indicates a node should pull all changes
|
||||||
|
NODE_FORCE_UPDATE = "force"
|
||||||
)
|
)
|
||||||
|
|
||||||
var seededRand *rand.Rand = rand.New(
|
var seededRand *rand.Rand = rand.New(
|
||||||
|
|
|
@ -141,3 +141,18 @@ func sendPeers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerStartNotify - notifies all non server nodes to pull changes after a restart
|
||||||
|
func ServerStartNotify() error {
|
||||||
|
nodes, err := logic.GetAllNodes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
nodes[i].Action = models.NODE_FORCE_UPDATE
|
||||||
|
if err = NodeUpdate(&nodes[i]); err != nil {
|
||||||
|
logger.Log(1, "error when notifying node", nodes[i].Name, " - ", nodes[i].ID, "of a server startup")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -87,6 +87,8 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ifaceDelta = true
|
ifaceDelta = true
|
||||||
|
case models.NODE_FORCE_UPDATE:
|
||||||
|
ifaceDelta = true
|
||||||
case models.NODE_NOOP:
|
case models.NODE_NOOP:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue