Skip to content

Commit

Permalink
[Controller] add pod_group_type
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-xiaofeng authored and SongZhen0704 committed Oct 9, 2023
1 parent d0394ae commit e196360
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cli/ctl/trisolaris_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ func formatString(data *trident.Interface) string {
buffer := bytes.Buffer{}
format := "Id: %d Mac: %s EpcId: %d DeviceType: %d DeviceId: %d IfType: %d" +
" LaunchServer: %s LaunchServerId: %d RegionId: %d AzId: %d, PodGroupId: %d, " +
"PodNsId: %d, PodId: %d, PodClusterId: %d, NetnsId: %d, VtapId: %d, IsVipInterface: %t "
"PodNsId: %d, PodId: %d, PodClusterId: %d, PodGroupType: %d, IsVipInterface: %t "
buffer.WriteString(fmt.Sprintf(format, data.GetId(), Uint64ToMac(data.GetMac()),
data.GetEpcId(), data.GetDeviceType(), data.GetDeviceId(), data.GetIfType(),
data.GetLaunchServer(), data.GetLaunchServerId(), data.GetRegionId(),
data.GetAzId(), data.GetPodGroupId(), data.GetPodNsId(), data.GetPodId(),
data.GetPodClusterId(), data.GetIsVipInterface()))
data.GetPodClusterId(), data.GetPodGroupType(), data.GetIsVipInterface()))
if data.GetPodNodeId() > 0 {
buffer.WriteString(fmt.Sprintf("PodNodeId: %d ", data.GetPodNodeId()))
}
Expand Down
2 changes: 1 addition & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/bitly/go-simplejson v0.5.0
github.com/deepflowio/deepflow/message v0.0.0-20230818083014-9c0740ae7cc8
github.com/deepflowio/deepflow/message v0.0.0-20231008013903-d0394ae13f57
github.com/deepflowio/deepflow/server v0.0.0-20230215120846-d4b50f72597d
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.5.2
Expand Down
4 changes: 2 additions & 2 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deepflowio/deepflow/message v0.0.0-20230818083014-9c0740ae7cc8 h1:P4M8KqtX+SNazJ6LZTpQsHXTHQOpIfZZBNosq7fS6JQ=
github.com/deepflowio/deepflow/message v0.0.0-20230818083014-9c0740ae7cc8/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/deepflow/message v0.0.0-20231008013903-d0394ae13f57 h1:Jz4dZtzF32jq6smaiLBZc3hdYnmsv7jZIAIWJbjTUh0=
github.com/deepflowio/deepflow/message v0.0.0-20231008013903-d0394ae13f57/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/deepflow/server v0.0.0-20230215120846-d4b50f72597d h1:mNkEWaK6IsZgzXATGOquVnl6EFIDnoAO1YP+0BomUHE=
github.com/deepflowio/deepflow/server v0.0.0-20230215120846-d4b50f72597d/go.mod h1:LRviMJ1kGzHOixRz5cteI2BnaxbuSQhmQvexguo9P+s=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
Expand Down
35 changes: 35 additions & 0 deletions server/controller/trisolaris/metadata/raw_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ import (
. "github.com/deepflowio/deepflow/server/controller/trisolaris/utils"
)

var PodGroupTypeMap = map[int]uint32{
POD_GROUP_DEPLOYMENT: uint32(trident.AutoServiceType_AUTO_SERVICE_TYPE_POD_GROUP_DEPLOYMENT),
POD_GROUP_STATEFULSET: uint32(trident.AutoServiceType_AUTO_SERVICE_TYPE_POD_GROUP_STATEFULSET),
POD_GROUP_RC: uint32(trident.AutoServiceType_AUTO_SERVICE_TYPE_POD_GROUP_RC),
POD_GROUP_DAEMON_SET: uint32(trident.AutoServiceType_AUTO_SERVICE_TYPE_POD_GROUP_DAEMON_SET),
POD_GROUP_REPLICASET_CONTROLLER: uint32(trident.AutoServiceType_AUTO_SERVICE_TYPE_POD_GROUP_REPLICASET_CONTROLLER),
}

type TypeIDData struct {
LaunchServer string
LaunchServerID int
Expand Down Expand Up @@ -97,6 +105,7 @@ type PlatformRawData struct {
peerConnIDs mapset.Set
cenIDs mapset.Set
podServiceIDs mapset.Set
podGroupIDs mapset.Set
redisInstanceIDs mapset.Set
rdsInstanceIDs mapset.Set
podNodeIDs mapset.Set
Expand All @@ -119,6 +128,7 @@ type PlatformRawData struct {
podServiceIDToPorts map[int][]*models.PodServicePort
idToPodNode map[int]*models.PodNode
idToPodService map[int]*models.PodService
idToPodGroup map[int]*models.PodGroup

vmIDToVifs map[int]mapset.Set
vRouterIDToVifs map[int]mapset.Set
Expand Down Expand Up @@ -162,6 +172,7 @@ func NewPlatformRawData() *PlatformRawData {
peerConnIDs: mapset.NewSet(),
cenIDs: mapset.NewSet(),
podServiceIDs: mapset.NewSet(),
podGroupIDs: mapset.NewSet(),
redisInstanceIDs: mapset.NewSet(),
rdsInstanceIDs: mapset.NewSet(),
podNodeIDs: mapset.NewSet(),
Expand Down Expand Up @@ -194,6 +205,7 @@ func NewPlatformRawData() *PlatformRawData {
vInterfaceIDToSimpleIP: make(map[int][]*trident.IpResource),
idToPodNode: make(map[int]*models.PodNode),
idToPodService: make(map[int]*models.PodService),
idToPodGroup: make(map[int]*models.PodGroup),

vmIDToVifs: make(map[int]mapset.Set),
vRouterIDToVifs: make(map[int]mapset.Set),
Expand Down Expand Up @@ -700,6 +712,17 @@ func (r *PlatformRawData) ConvertDBPodService(dbDataCache *DBDataCache) {
}
}

func (r *PlatformRawData) ConvertDBPodGroup(dbDataCache *DBDataCache) {
podGroups := dbDataCache.GetPodGroups()
if podGroups == nil {
return
}
for _, pg := range podGroups {
r.idToPodGroup[pg.ID] = pg
r.podGroupIDs.Add(pg.ID)
}
}

func (r *PlatformRawData) ConvertDBPodServicePort(dbDataCache *DBDataCache) {
podServicePorts := dbDataCache.GetPodServicePorts()
if podServicePorts == nil {
Expand Down Expand Up @@ -1037,6 +1060,7 @@ func (r *PlatformRawData) ConvertDBCache(dbDataCache *DBDataCache) {
r.ConvertDBPeerConnection(dbDataCache)
r.ConvertDBCEN(dbDataCache)
r.ConvertDBPodService(dbDataCache)
r.ConvertDBPodGroup(dbDataCache)
r.ConvertDBPodServicePort(dbDataCache)
r.ConvertDBRedisInstance(dbDataCache)
r.ConvertDBRdsInstance(dbDataCache)
Expand Down Expand Up @@ -1096,6 +1120,11 @@ func (r *PlatformRawData) vInterfaceToProto(
if err != nil {
log.Error(err, vif.Mac)
}
podGroupType := uint32(0)
podGroup := r.idToPodGroup[device.PodGroupID]
if podGroup != nil {
podGroupType = PodGroupTypeMap[podGroup.Type]
}
aInterface := &trident.Interface{
Id: proto.Uint32(uint32(vif.ID)),
Mac: proto.Uint64(macU64),
Expand All @@ -1114,6 +1143,7 @@ func (r *PlatformRawData) vInterfaceToProto(
PodNodeId: proto.Uint32(uint32(device.PodNodeID)),
PodId: proto.Uint32(uint32(device.PodID)),
IsVipInterface: proto.Bool(ipResourceData.isVipInterface),
PodGroupType: proto.Uint32(podGroupType),
}

sInterface := &trident.Interface{
Expand Down Expand Up @@ -1387,6 +1417,11 @@ func (r *PlatformRawData) equal(o *PlatformRawData) bool {
return false
}

if !r.podGroupIDs.Equal(o.podGroupIDs) {
log.Info("platform pod group changed")
return false
}

if !r.redisInstanceIDs.Equal(o.redisInstanceIDs) {
log.Info("platform redis instance changed")
return false
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/cactus/go-statsd-client/v5 v5.0.0
github.com/deckarep/golang-set v1.8.0
github.com/deckarep/golang-set/v2 v2.1.0
github.com/deepflowio/deepflow/message v0.0.0-20230907024218-d3e82c775457
github.com/deepflowio/deepflow/message v0.0.0-20231008013903-d0394ae13f57
github.com/deepflowio/deepflow/server/controller/cloud/platform v0.0.0-00010101000000-000000000000
github.com/deepflowio/deepflow/server/controller/db/mysql/migrator v0.0.0-00010101000000-000000000000
github.com/deepflowio/deepflow/server/controller/monitor/license v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsP
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/deepflowio/deepflow/message v0.0.0-20230907024218-d3e82c775457 h1:JQ8zwSyoJHqsXHkSEk4/H0anWBqPP+rDkxw8LOTh40I=
github.com/deepflowio/deepflow/message v0.0.0-20230907024218-d3e82c775457/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/deepflow/message v0.0.0-20231008013903-d0394ae13f57 h1:Jz4dZtzF32jq6smaiLBZc3hdYnmsv7jZIAIWJbjTUh0=
github.com/deepflowio/deepflow/message v0.0.0-20231008013903-d0394ae13f57/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/tempopb v0.0.0-20230215110519-15853baf3a79 h1:erRwXyZiUZxxZX/Q1QHesZXgxjiunZUFy+ggCRimkD4=
github.com/deepflowio/tempopb v0.0.0-20230215110519-15853baf3a79/go.mod h1:h2rkZ319TExIUGuK8a2dlcGd8qc6wdhsrcpXWaJQaQE=
github.com/dennwc/varint v1.0.0 h1:kGNFFSSw8ToIy3obO/kKr8U9GZYUAxQEVuix4zfDWzE=
Expand Down

0 comments on commit e196360

Please sign in to comment.