From fa72331202b36fda5ce69ef7b196f26412db2fac Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Tue, 9 Dec 2025 14:58:03 +0400 Subject: [PATCH 1/3] add debug trace --- mq/publishers.go | 2 ++ utils/utils.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mq/publishers.go b/mq/publishers.go index 1059480fb..417683002 100644 --- a/mq/publishers.go +++ b/mq/publishers.go @@ -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 } diff --git a/utils/utils.go b/utils/utils.go index cc44bb95f..4fb9c096b 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -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 From 95205b499a356546ed2a2028f6eab1c7cbca17fc Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Tue, 9 Dec 2025 15:02:57 +0400 Subject: [PATCH 2/3] add debug trace --- mq/util.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mq/util.go b/mq/util.go index e9871ccfb..0ef98a448 100644 --- a/mq/util.go +++ b/mq/util.go @@ -16,6 +16,7 @@ import ( "github.com/gravitl/netmaker/logic" "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/netclient/ncutils" + "github.com/gravitl/netmaker/utils" "golang.org/x/exp/slog" ) @@ -134,7 +135,7 @@ func encryptMsg(host *models.Host, msg []byte) ([]byte, error) { } func publish(host *models.Host, dest string, msg []byte) error { - + utils.TraceCaller() var encrypted []byte var encryptErr error vlt, err := logic.VersionLessThan(host.Version, "v0.30.0") From e8ecf1ec948ddefb41220f6abe155108849f1f1a Mon Sep 17 00:00:00 2001 From: abhishek9686 Date: Tue, 9 Dec 2025 15:54:06 +0400 Subject: [PATCH 3/3] add debug trace --- controllers/hosts.go | 13 +++++++++++++ mq/publishers.go | 1 + mq/util.go | 2 -- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/controllers/hosts.go b/controllers/hosts.go index 38e454a67..d9c4d75ad 100644 --- a/controllers/hosts.go +++ b/controllers/hosts.go @@ -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}) @@ -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) @@ -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: @@ -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: @@ -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) diff --git a/mq/publishers.go b/mq/publishers.go index 417683002..b23358c29 100644 --- a/mq/publishers.go +++ b/mq/publishers.go @@ -57,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 } diff --git a/mq/util.go b/mq/util.go index 0ef98a448..8aff793b0 100644 --- a/mq/util.go +++ b/mq/util.go @@ -16,7 +16,6 @@ import ( "github.com/gravitl/netmaker/logic" "github.com/gravitl/netmaker/models" "github.com/gravitl/netmaker/netclient/ncutils" - "github.com/gravitl/netmaker/utils" "golang.org/x/exp/slog" ) @@ -135,7 +134,6 @@ func encryptMsg(host *models.Host, msg []byte) ([]byte, error) { } func publish(host *models.Host, dest string, msg []byte) error { - utils.TraceCaller() var encrypted []byte var encryptErr error vlt, err := logic.VersionLessThan(host.Version, "v0.30.0")