Merge pull request #121 from zryfish/fix_heapster_client
Add error check to heapsterclient response
This commit is contained in:
@@ -27,8 +27,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/models/metrics"
|
||||
)
|
||||
|
||||
const inUse = "kubesphere.io/in_use_pods"
|
||||
@@ -269,22 +267,6 @@ func (ctl *PodCtl) ListWithConditions(conditions string, paging *Paging) (int, i
|
||||
|
||||
listWithConditions(ctl.DB, &total, &object, &list, conditions, paging, order)
|
||||
|
||||
ch := make(chan metrics.PodMetrics)
|
||||
|
||||
for index, _ := range list {
|
||||
go metrics.GetSinglePodMetrics(list[index].Namespace, list[index].Name, ch)
|
||||
}
|
||||
|
||||
var resultMetrics = make(map[string]metrics.PodMetrics)
|
||||
for range list {
|
||||
podMetric := <-ch
|
||||
resultMetrics[podMetric.PodName] = podMetric
|
||||
}
|
||||
|
||||
for index, _ := range list {
|
||||
list[index].Metrics = resultMetrics[list[index].Name]
|
||||
}
|
||||
|
||||
return total, list, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/models/metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -179,17 +177,16 @@ func (Ingress) TableName() string {
|
||||
}
|
||||
|
||||
type Pod struct {
|
||||
Name string `gorm:"primary_key" json:"name"`
|
||||
Namespace string `gorm:"primary_key" json:"namespace"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Node string `json:"node,omitempty"`
|
||||
NodeIp string `json:"nodeIp,omitempty"`
|
||||
PodIp string `json:"podIp,omitempty"`
|
||||
Containers Containers `gorm:"type:text" json:"containers,omitempty"`
|
||||
Annotation Annotation `json:"annotations"`
|
||||
RestartCount int `json:"restartCount"`
|
||||
Metrics metrics.PodMetrics `json:"metrics,omitempty"`
|
||||
CreateTime time.Time `gorm:"column:createTime" json:"createTime,omitempty"`
|
||||
Name string `gorm:"primary_key" json:"name"`
|
||||
Namespace string `gorm:"primary_key" json:"namespace"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Node string `json:"node,omitempty"`
|
||||
NodeIp string `json:"nodeIp,omitempty"`
|
||||
PodIp string `json:"podIp,omitempty"`
|
||||
Containers Containers `gorm:"type:text" json:"containers,omitempty"`
|
||||
Annotation Annotation `json:"annotations"`
|
||||
RestartCount int `json:"restartCount"`
|
||||
CreateTime time.Time `gorm:"column:createTime" json:"createTime,omitempty"`
|
||||
}
|
||||
|
||||
type Container struct {
|
||||
|
||||
Reference in New Issue
Block a user