feat(region): add container info into server details (#20544)

This commit is contained in:
Zexi Li
2024-06-14 19:19:12 +08:00
committed by GitHub
parent f88f91eab9
commit ad4d0abd41
2 changed files with 25 additions and 0 deletions
+9
View File
@@ -274,6 +274,15 @@ type ServerDetails struct {
// 监控上报URL
MonitorUrl string `json:"monitor_url"`
// 容器描述信息
Containers []*PodContainerDesc `json:"containers"`
}
type PodContainerDesc struct {
Id string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
}
type Floppy struct {
+16
View File
@@ -2612,6 +2612,22 @@ func (self *SGuest) moreExtraInfo(
out.MonitorUrl = drv.FetchMonitorUrl(ctx, self)
}
if drv != nil && drv.GetHypervisor() == api.HYPERVISOR_POD {
ctrs, _ := GetContainerManager().GetContainersByPod(self.GetId())
desc := make([]*api.PodContainerDesc, len(ctrs))
for i := range ctrs {
ctr := ctrs[i]
desc[i] = &api.PodContainerDesc{
Id: ctr.GetId(),
Name: ctr.GetName(),
}
if ctr.Spec != nil {
desc[i].Image = ctr.Spec.Image
}
}
out.Containers = desc
}
return out
}