Skip to content

Commit 4d0b74a

Browse files
committed
feat: support update vtap az
1 parent 74c7990 commit 4d0b74a

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

server/controller/cloud/kubernetes_gather/plugin/plugin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func GeneratePodGroup(orgID int, db *gorm.DB, metaData *simplejson.Json) (string
3939
return "", "", err
4040
}
4141

42+
if len(plugins) == 0 {
43+
return "", "", nil
44+
}
45+
4246
// TODO: convert to lua script
4347
podGroupType, podGroupName := customSCIPodGroup(orgID, metaData)
4448
if podGroupType != "" && podGroupName != "" {

server/controller/monitor/vtap/vtap.go

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ func (v *VTapCheck) launchServerCheck(db *metadb.DB) {
9494

9595
log.Debugf("vtap launch_server check start", db.LogPrefixORGID)
9696

97-
db.Select("id", "lcuuid", "name", "region").Find(&vms)
97+
db.Select("id", "lcuuid", "name", "region", "az").Find(&vms)
9898
lcuuidToVM := make(map[string]metadbmodel.VM)
9999
for _, vm := range vms {
100100
lcuuidToVM[vm.Lcuuid] = vm
101101
}
102102

103-
db.Select("id", "lcuuid", "name", "region").Find(&podNodes)
103+
db.Select("id", "lcuuid", "name", "region", "az").Find(&podNodes)
104104
lcuuidToPodNode := make(map[string]metadbmodel.PodNode)
105105
for _, podNode := range podNodes {
106106
lcuuidToPodNode[podNode.Lcuuid] = podNode
@@ -140,6 +140,14 @@ func (v *VTapCheck) launchServerCheck(db *metadb.DB) {
140140
)
141141
db.Model(&vtap).Update("region", vm.Region)
142142
}
143+
// check and update az
144+
if vtap.AZ != vm.AZ {
145+
log.Infof(
146+
"update vtap (%s) az from %s to %s",
147+
vtap.Lcuuid, vtap.AZ, vm.AZ, db.LogPrefixORGID,
148+
)
149+
db.Model(&vtap).Update("az", vm.AZ)
150+
}
143151
}
144152

145153
case common.VTAP_TYPE_KVM, common.VTAP_TYPE_ESXI, common.VTAP_TYPE_HYPER_V:
@@ -173,6 +181,14 @@ func (v *VTapCheck) launchServerCheck(db *metadb.DB) {
173181
)
174182
db.Model(&vtap).Update("region", host.Region)
175183
}
184+
// check and update az
185+
if vtap.AZ != host.AZ {
186+
log.Infof(
187+
"update vtap (%s) az from %s to %s",
188+
vtap.Lcuuid, vtap.AZ, host.AZ, db.LogPrefixORGID,
189+
)
190+
db.Model(&vtap).Update("az", host.AZ)
191+
}
176192
}
177193
case common.VTAP_TYPE_POD_HOST, common.VTAP_TYPE_POD_VM:
178194
podNode, ok := lcuuidToPodNode[vtap.Lcuuid]
@@ -210,6 +226,14 @@ func (v *VTapCheck) launchServerCheck(db *metadb.DB) {
210226
)
211227
db.Model(&vtap).Update("region", podNode.Region)
212228
}
229+
// check and update az
230+
if vtap.AZ != podNode.AZ {
231+
log.Infof(
232+
"update vtap (%s) az from %s to %s",
233+
vtap.Lcuuid, vtap.AZ, podNode.AZ, db.LogPrefixORGID,
234+
)
235+
db.Model(&vtap).Update("az", podNode.AZ)
236+
}
213237
}
214238
case common.VTAP_TYPE_K8S_SIDECAR:
215239
var pod metadbmodel.Pod
@@ -242,6 +266,13 @@ func (v *VTapCheck) launchServerCheck(db *metadb.DB) {
242266
)
243267
db.Model(&vtap).Update("region", pod.Region)
244268
}
269+
if vtap.AZ != pod.AZ {
270+
log.Infof(
271+
"update vtap (%s) az from %s to %s",
272+
vtap.Lcuuid, vtap.AZ, pod.AZ, db.LogPrefixORGID,
273+
)
274+
db.Model(&vtap).Update("az", pod.AZ)
275+
}
245276
}
246277
}
247278
}

server/controller/trisolaris/services/grpc/agentsynchronize/sync_push.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ func (e *AgentEvent) Push(r *api.SyncRequest, in api.Synchronizer_PushServer) er
687687

688688
if !enabledPush {
689689
firstPush = false
690+
in.Send(&api.SyncResponse{Status: &STATUS_HEARTBEAT})
690691
log.Debugf("push disabled for agent (%s-%s)", r.GetCtrlIp(), r.GetCtrlMac(), logger.NewORGPrefix(orgID))
691692
continue
692693
}

0 commit comments

Comments
 (0)