Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions controllers/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
switch hostUpdate.Action {
case models.CheckIn:
sendPeerUpdate = mq.HandleHostCheckin(&hostUpdate.Host, currentHost)
if sendPeerUpdate {
fmt.Println("====> hostUpdateFallback", hostUpdate.Action, hostUpdate.Host.Name)
}
changed := logic.CheckHostPorts(currentHost)
if changed {
mq.HostUpdate(&models.HostUpdate{Action: models.UpdateHost, Host: *currentHost})
Expand All @@ -401,6 +404,9 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
replacePeers = true
}
sendPeerUpdate = logic.UpdateHostFromClient(&hostUpdate.Host, currentHost)
if sendPeerUpdate {
fmt.Println("====> hostUpdateFallback", hostUpdate.Action, hostUpdate.Host.Name)
}
err := logic.UpsertHost(currentHost)
if err != nil {
slog.Error("failed to update host", "id", currentHost.ID, "error", err)
Expand All @@ -409,6 +415,9 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
}
case models.UpdateNode:
sendDeletedNodeUpdate, sendPeerUpdate = logic.UpdateHostNode(&hostUpdate.Host, &hostUpdate.Node)
if sendPeerUpdate {
fmt.Println("====> hostUpdateFallback", hostUpdate.Action, hostUpdate.Host.Name)
}
case models.UpdateMetrics:
mq.UpdateMetricsFallBack(hostUpdate.Node.ID.String(), hostUpdate.NewMetrics)
case models.EgressUpdate:
Expand All @@ -423,6 +432,9 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
e.Update(db.WithContext(r.Context()))
}
sendPeerUpdate = true
if sendPeerUpdate {
fmt.Println("====> hostUpdateFallback", hostUpdate.Action, hostUpdate.Host.Name)
}
case models.SignalHost:
mq.SignalPeer(hostUpdate.Signal)
case models.DeleteHost:
Expand All @@ -433,6 +445,7 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
mq.PublishDeletedNodePeerUpdate(&hostUpdate.Node)
}
if sendPeerUpdate {
fmt.Println("======> Sending Peer update: hostUpdateFallback")
err := mq.PublishPeerUpdate(replacePeers)
if err != nil {
slog.Error("failed to publish peer update", "error", err)
Expand Down
3 changes: 3 additions & 0 deletions mq/publishers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/servercfg"
"github.com/gravitl/netmaker/utils"
"golang.org/x/exp/slog"
)

// PublishPeerUpdate --- determines and publishes a peer update to all the hosts
func PublishPeerUpdate(replacePeers bool) error {
utils.TraceCaller()
if !servercfg.IsMessageQueueBackend() {
return nil
}
Expand Down Expand Up @@ -55,6 +57,7 @@ func PublishPeerUpdate(replacePeers bool) error {
// PublishDeletedNodePeerUpdate --- determines and publishes a peer update
// to all the hosts with a deleted node to account for
func PublishDeletedNodePeerUpdate(delNode *models.Node) error {
utils.TraceCaller()
if !servercfg.IsMessageQueueBackend() {
return nil
}
Expand Down
1 change: 0 additions & 1 deletion mq/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func encryptMsg(host *models.Host, msg []byte) ([]byte, error) {
}

func publish(host *models.Host, dest string, msg []byte) error {

var encrypted []byte
var encryptErr error
vlt, err := logic.VersionLessThan(host.Version, "v0.30.0")
Expand Down
4 changes: 2 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func TraceCaller() {
funcName := runtime.FuncForPC(pc).Name()

// Print trace details
slog.Debug("## TRACE -> Called from function: ", "tracing-func-name", traceFuncName, "caller-func-name", funcName)
slog.Debug("## TRACE -> Caller File Info", "file", file, "line-no", line)
fmt.Println("## TRACE -> Called from function: ", "tracing-func-name", traceFuncName, "caller-func-name", funcName)
fmt.Println("## TRACE -> Caller File Info", "file", file, "line-no", line)
}

// NoEmptyStringToCsv takes a bunch of strings, filters out empty ones and returns a csv version of the string
Expand Down