Skip to content

Commit

Permalink
[Controller] debug sync by orgid
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-xiaofeng committed Jun 17, 2024
1 parent bb66efb commit c2cdc98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions cli/ctl/trisolaris_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func initCmd(cmd *cobra.Command, cmds []CmdExecute) {
groupID = paramData.GroupID
clusterID = paramData.ClusterID
teamID = paramData.TeamID
orgID = paramData.OrgID
case "analyzer":
name = paramData.Type
orgID = paramData.OrgID
Expand Down
10 changes: 8 additions & 2 deletions server/controller/trisolaris/services/grpc/synchronize/vtap.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,14 @@ func (e *VTapEvent) Sync(ctx context.Context, in *api.SyncRequest) (*api.SyncRes
orgID, teamIDInt := trisolaris.GetOrgInfoByTeamID(teamIDStr)
gVTapInfo := trisolaris.GetORGVTapInfo(orgID)
if gVTapInfo == nil {
log.Errorf("ORGID-%d: ctrlIp is %s, ctrlMac is %s, team_id is (str=%s,int=%d) not found vtapInfo", orgID, ctrlIP, ctrlMac, teamIDStr, teamIDInt)
return e.GetFailedResponse(in, gVTapInfo), nil
if rOrgID := int(in.GetOrgId()); rOrgID != 0 {
orgID = rOrgID
gVTapInfo = trisolaris.GetORGVTapInfo(rOrgID)
}
if gVTapInfo == nil {
log.Errorf("ORGID-%d: ctrlIp is %s, ctrlMac is %s, team_id is (str=%s,int=%d) not found vtapInfo", orgID, ctrlIP, ctrlMac, teamIDStr, teamIDInt)
return e.GetFailedResponse(in, gVTapInfo), nil
}
}
vtapCacheKey := ctrlIP + "-" + ctrlMac
vtapCache, err := e.getVTapCache(in, orgID)
Expand Down
16 changes: 10 additions & 6 deletions server/controller/trisolaris/trisolaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ func NewTrisolarisManager(cfg *config.Config, db *gorm.DB) *TrisolarisManager {
}

func (m *TrisolarisManager) Start() error {
go m.TimedCheckORG()
go m.refreshOP.TimedRefreshIPs()
m.startTime = getStartTime()
orgIDs, err := mysql.GetORGIDs()
Expand All @@ -367,9 +366,11 @@ func (m *TrisolarisManager) Start() error {
}
log.Infof("get orgIDs : %v", orgIDs)
trisolaris := NewTrisolaris(m.config, mysql.DefaultDB, m.ctx, m.startTime)
trisolaris.Start()
m.orgToTrisolaris[DEFAULT_ORG_ID] = trisolaris
for _, orgID := range orgIDs {
go trisolaris.Start()
orgIDsUint32 := make([]uint32, len(orgIDs), len(orgIDs))
for index, orgID := range orgIDs {
orgIDsUint32[index] = uint32(orgID)
if utils.CheckOrgID(orgID) == false || orgID == DEFAULT_ORG_ID {
continue
}
Expand All @@ -379,10 +380,13 @@ func (m *TrisolarisManager) Start() error {
continue
}
trisolaris := NewTrisolaris(m.config, orgDB, m.ctx, m.startTime)
trisolaris.Start()
m.orgToTrisolaris[orgID] = trisolaris
go trisolaris.Start()
}

m.orgIDData = &trident.OrgIDsResponse{
OrgIds: orgIDsUint32,
}
go m.TimedCheckORG()
m.getTeamData(orgIDs)
log.Infof("finish orgdata init %v", orgIDs)
return nil
Expand Down Expand Up @@ -496,8 +500,8 @@ func (m *TrisolarisManager) checkORG() {
continue
}
trisolaris := NewTrisolaris(m.config, orgDB, m.ctx, m.startTime)
trisolaris.Start()
m.orgToTrisolaris[orgID] = trisolaris
go trisolaris.Start()
}
}
}
Expand Down

0 comments on commit c2cdc98

Please sign in to comment.