Skip to content

Commit

Permalink
fix: agent cmd panic
Browse files Browse the repository at this point in the history
  • Loading branch information
roryye committed Jul 31, 2024
1 parent b4b1d3d commit c417601
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/controller/http/router/agent_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func forwardToServerConnectedByAgent() gin.HandlerFunc {
newHost := common.NodeIP
if common.NodeIP == agent.CurControllerIP {
if manager := service.GetAgentCMDManager(key); manager != nil {
log.Infof("agent(key: %s) command context next, node ip(%s)", key)
c.Next()
return
} else {
Expand All @@ -148,6 +149,7 @@ func forwardToServerConnectedByAgent() gin.HandlerFunc {
}
} else if common.NodeIP == agent.ControllerIP {
if manager := service.GetAgentCMDManager(key); manager != nil {
log.Infof("agent(key: %s) command context next, node ip(%s)", key)
c.Next()
return
} else {
Expand Down Expand Up @@ -177,6 +179,7 @@ func forwardToServerConnectedByAgent() gin.HandlerFunc {
}

func (a *AgentCMD) getCMDAndNamespaceHandler() gin.HandlerFunc {
log.Infof("weiqiang getCMDAndNamespaceHandler")
return func(c *gin.Context) {
orgID, _ := c.Get(common.HEADER_KEY_X_ORG_ID)
db, err := mysql.GetDB(orgID.(int))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io"
"runtime"
"sync"

"github.com/deepflowio/deepflow/message/trident"
api "github.com/deepflowio/deepflow/message/trident"
Expand All @@ -31,7 +32,10 @@ import (

func (e *VTapEvent) RemoteExecute(stream api.Synchronizer_RemoteExecuteServer) error {
key := ""
var wg sync.WaitGroup
wg.Add(1)
defer func() {
wg.Wait()
service.RemoveAllFromCMDManager(key)
}()

Expand All @@ -43,6 +47,7 @@ func (e *VTapEvent) RemoteExecute(stream api.Synchronizer_RemoteExecuteServer) e

go func() {
defer func() {
wg.Done()
if r := recover(); r != nil {
buf := make([]byte, 2048)
n := runtime.Stack(buf, false)
Expand Down

0 comments on commit c417601

Please sign in to comment.