mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 05:34:38 +08:00
Merge branch 'GRA-985/host_updates_logic' of https://github.com/gravitl/netmaker into GRA-985/host_delete_logic
This commit is contained in:
commit
83ea8778d6
4 changed files with 8 additions and 6 deletions
|
@ -109,10 +109,12 @@ func updateHost(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
// publish host update through MQ
|
||||
mq.HostUpdate(&models.HostUpdate{
|
||||
if mq.HostUpdate(&models.HostUpdate{
|
||||
Action: models.UpdateHost,
|
||||
Host: *newHost,
|
||||
})
|
||||
}); err != nil {
|
||||
logger.Log(0, r.Header.Get("user"), "failed to send host update: ", currHost.ID.String(), err.Error())
|
||||
}
|
||||
go func() {
|
||||
if err := mq.PublishPeerUpdate(); err != nil {
|
||||
logger.Log(0, "fail to publish peer update: ", err.Error())
|
||||
|
|
|
@ -186,7 +186,7 @@ func fetchHostAcls(hostID string) []Acl {
|
|||
},
|
||||
{
|
||||
AclType: "publishClientSend",
|
||||
Topic: fmt.Sprintf("host/update/%s", hostID),
|
||||
Topic: fmt.Sprintf("host/serverupdate/%s", hostID),
|
||||
Priority: -1,
|
||||
Allow: true,
|
||||
},
|
||||
|
@ -373,7 +373,7 @@ func fetchServerAcls() []Acl {
|
|||
},
|
||||
{
|
||||
AclType: "publishClientReceive",
|
||||
Topic: "host/update/#",
|
||||
Topic: "host/serverupdate/#",
|
||||
Priority: -1,
|
||||
Allow: true,
|
||||
},
|
||||
|
|
|
@ -141,7 +141,7 @@ func UpdateHost(client mqtt.Client, msg mqtt.Message) {
|
|||
logger.Log(1, "error unmarshaling payload ", err.Error())
|
||||
return
|
||||
}
|
||||
logger.Log(0, fmt.Sprintf("recieved host update: %+v\n", hostUpdate))
|
||||
logger.Log(0, "recieved host update for host: ", id)
|
||||
var sendPeerUpdate bool
|
||||
switch hostUpdate.Action {
|
||||
case models.UpdateHost:
|
||||
|
|
2
mq/mq.go
2
mq/mq.go
|
@ -83,7 +83,7 @@ func SetupMQTT() {
|
|||
client.Disconnect(240)
|
||||
logger.Log(0, "node update subscription failed")
|
||||
}
|
||||
if token := client.Subscribe("host/update/#", 0, mqtt.MessageHandler(UpdateHost)); token.WaitTimeout(MQ_TIMEOUT*time.Second) && token.Error() != nil {
|
||||
if token := client.Subscribe("host/serverupdate/#", 0, mqtt.MessageHandler(UpdateHost)); token.WaitTimeout(MQ_TIMEOUT*time.Second) && token.Error() != nil {
|
||||
client.Disconnect(240)
|
||||
logger.Log(0, "host update subscription failed")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue