Merge pull request #286 from GLYASAI/RAINBOND-925

[FIX] wrong calculation for available memory
This commit is contained in:
barnettZQG 2019-05-14 05:42:31 -05:00 committed by GitHub
commit 875624c24a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 309 additions and 102 deletions

View File

@ -25,14 +25,12 @@ import (
"os"
"strings"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/db"
"github.com/pquerna/ffjson/ffjson"
"github.com/Sirupsen/logrus"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/db/model"
"github.com/pquerna/ffjson/ffjson"
)
//PubChargeSverify service Charge Sverify
@ -91,7 +89,8 @@ func PriChargeSverify(tenant *model.Tenants, quantity int) *util.APIHandleError
return util.CreateAPIHandleError(200, fmt.Errorf("cluster_lack_of_memory"))
}
tenantStas, err := handler.GetTenantManager().GetTenantResource(tenant.UUID)
availMem := int64(t.LimitMemory) - tenantStas.MemoryRequest
// TODO: it should be limit, not request
availMem := int64(t.LimitMemory) - (tenantStas.MemoryRequest + tenantStas.UnscdMemoryReq)
if availMem >= int64(quantity) {
return util.CreateAPIHandleError(200, fmt.Errorf("success"))
}

View File

@ -25,11 +25,10 @@ import (
"strconv"
"strings"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/Sirupsen/logrus"
api_model "github.com/goodrain/rainbond/api/model"
"github.com/goodrain/rainbond/api/util"
"github.com/goodrain/rainbond/cmd/api/option"
"github.com/goodrain/rainbond/db"
dbmodel "github.com/goodrain/rainbond/db/model"
"github.com/goodrain/rainbond/mq/api/grpc/pb"
@ -243,12 +242,16 @@ func (t *TenantAction) GetTenantsResources(tr *api_model.TenantResources) (map[s
//TenantResourceStats tenant resource stats
type TenantResourceStats struct {
TenantID string `json:"tenant_id,omitempty"`
CPURequest int64 `json:"cpu_request,omitempty"`
CPULimit int64 `json:"cpu_limit,omitempty"`
MemoryRequest int64 `json:"memory_request,omitempty"`
MemoryLimit int64 `json:"memory_limit,omitempty"`
RunningAppNum int64 `json:"running_app_num"`
TenantID string `json:"tenant_id,omitempty"`
CPURequest int64 `json:"cpu_request,omitempty"`
CPULimit int64 `json:"cpu_limit,omitempty"`
MemoryRequest int64 `json:"memory_request,omitempty"`
MemoryLimit int64 `json:"memory_limit,omitempty"`
RunningAppNum int64 `json:"running_app_num"`
UnscdCPUReq int64 `json:"unscd_cpu_req,omitempty"`
UnscdCPULimit int64 `json:"unscd_cpu_limit,omitempty"`
UnscdMemoryReq int64 `json:"unscd_memory_req,omitempty"`
UnscdMemoryLimit int64 `json:"unscd_memory_limit,omitempty"`
}
//GetTenantResource get tenant resource

View File

@ -501,7 +501,8 @@ func (k *kubeClient) GetNodes() ([]*v1.Node, error) {
if err != nil {
return nil, err
}
for _, node := range list.Items {
for idx := range list.Items {
node := list.Items[idx]
nodes = append(nodes, &node)
}
}

View File

@ -0,0 +1,46 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package test
import (
"testing"
"time"
"github.com/goodrain/rainbond/cmd/node/option"
"github.com/goodrain/rainbond/node/kubecache"
)
func TestGetCluster(t *testing.T) {
c := &option.Conf{
K8SConfPath: "/opt/rainbond/etc/kubernetes/kubecfg/admin.kubeconfig",
MinResyncPeriod: 10 * time.Second,
}
kubecli, err := kubecache.NewKubeClient(c)
if err != nil {
t.Fatalf("error creating kube client: %v", err)
}
defer kubecli.Stop()
nodes, err := kubecli.GetNodes()
if err != nil {
t.Errorf("error getting nodes: %v", err)
}
t.Log(nodes)
t.Error("")
}

View File

@ -33,6 +33,7 @@ type Informer struct {
ConfigMap cache.SharedIndexInformer
ReplicaSet cache.SharedIndexInformer
Endpoints cache.SharedIndexInformer
Nodes cache.SharedIndexInformer
}
//Start statrt
@ -46,13 +47,14 @@ func (i *Informer) Start(stop chan struct{}) {
go i.ConfigMap.Run(stop)
go i.ReplicaSet.Run(stop)
go i.Endpoints.Run(stop)
go i.Nodes.Run(stop)
}
//Ready if all kube informers is syncd, store is ready
func (i *Informer) Ready() bool {
if i.Ingress.HasSynced() && i.Service.HasSynced() && i.Secret.HasSynced() &&
i.StatefulSet.HasSynced() && i.Deployment.HasSynced() && i.Pod.HasSynced() &&
i.ConfigMap.HasSynced() {
i.ConfigMap.HasSynced() && i.Nodes.HasSynced() {
return true
}
return false

View File

@ -34,4 +34,5 @@ type Lister struct {
Pod corev1.PodLister
ConfigMap corev1.ConfigMapLister
Endpoints corev1.EndpointsLister
Nodes corev1.NodeLister
}

View File

@ -155,6 +155,9 @@ func NewStore(clientset *kubernetes.Clientset,
store.informers.Endpoints = infFactory.Core().V1().Endpoints().Informer()
store.listers.Endpoints = infFactory.Core().V1().Endpoints().Lister()
store.informers.Nodes = infFactory.Core().V1().Nodes().Informer()
store.listers.Nodes = infFactory.Core().V1().Nodes().Lister()
isThirdParty := func(ep *corev1.Endpoints) bool {
return ep.Labels["service-kind"] == model.ServiceKindThirdParty.String()
}
@ -245,6 +248,7 @@ func NewStore(clientset *kubernetes.Clientset,
store.informers.ConfigMap.AddEventHandlerWithResyncPeriod(store, time.Second*10)
store.informers.ReplicaSet.AddEventHandlerWithResyncPeriod(store, time.Second*10)
store.informers.Endpoints.AddEventHandlerWithResyncPeriod(epEventHandler, time.Second*10)
store.informers.Nodes.AddEventHandlerWithResyncPeriod(store, time.Second*10)
return store
}
@ -523,6 +527,9 @@ func (a *appRuntimeStore) OnAdd(obj interface{}) {
}
}
}
if node, ok := obj.(*corev1.Node); ok {
logrus.Debugf("Node: %s", node.Name)
}
}
//getAppService if creater is true, will create new app service where not found in store
@ -918,41 +925,70 @@ func (a *appRuntimeStore) GetPodLister() listcorev1.PodLister {
//GetTenantResource get tenant resource
func (a *appRuntimeStore) GetTenantResource(tenantID string) *v1.TenantResource {
nodes, err := a.listers.Nodes.List(labels.Everything())
if err != nil {
logrus.Errorf("error listing nodes: %v", err)
return nil
}
nodeStatus := make(map[string]bool, len(nodes))
for _, node := range nodes {
nodeStatus[node.Name] = node.Spec.Unschedulable
}
pods, err := a.listers.Pod.Pods(tenantID).List(labels.Everything())
if err != nil {
logrus.Errorf("list namespace %s pod failure %s", tenantID, err.Error())
return nil
}
var resource v1.TenantResource
for _, pod := range pods {
calculateResourcesfunc := func(pod *corev1.Pod, res map[string]int64) {
for _, container := range pod.Spec.Containers {
cpulimit := container.Resources.Limits.Cpu()
memorylimit := container.Resources.Limits.Memory()
cpurequest := container.Resources.Requests.Cpu()
memoryrequest := container.Resources.Requests.Memory()
if cpulimit != nil {
resource.CPULimit += cpulimit.MilliValue()
res["cpulimit"] += cpulimit.MilliValue()
}
if memorylimit != nil {
if ml, ok := memorylimit.AsInt64(); ok {
resource.MemoryLimit += ml
res["memlimit"] += ml
} else {
resource.MemoryLimit += memorylimit.Value()
res["memlimit"] += memorylimit.Value()
}
}
if cpurequest != nil {
resource.CPURequest += cpurequest.MilliValue()
res["cpureq"] += cpurequest.MilliValue()
}
if memoryrequest != nil {
if mr, ok := memoryrequest.AsInt64(); ok {
resource.MemoryRequest += mr
res["memreq"] += mr
} else {
resource.MemoryRequest += memoryrequest.Value()
res["memreq"] += memoryrequest.Value()
}
}
}
}
return &resource
resource := &v1.TenantResource{}
// schedulable resources
sres := make(map[string]int64)
// unschedulable resources
ures := make(map[string]int64)
for _, pod := range pods {
if nodeStatus[pod.Spec.NodeName] {
calculateResourcesfunc(pod, ures)
continue
}
calculateResourcesfunc(pod, sres)
}
resource.CPULimit = sres["cpulimit"]
resource.CPURequest = sres["cpureq"]
resource.MemoryLimit = sres["memlimit"]
resource.MemoryRequest = sres["memreq"]
resource.UnscdCPULimit = ures["cpulimit"]
resource.UnscdCPUReq = ures["cpureq"]
resource.UnscdMemoryLimit = ures["memlimit"]
resource.UnscdMemoryReq = ures["memreq"]
return resource
}
//GetTenantRunningApp get running app by tenant

View File

@ -0,0 +1,73 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package store
import (
"github.com/eapache/channels"
"github.com/goodrain/rainbond/cmd/worker/option"
"github.com/goodrain/rainbond/db"
"github.com/goodrain/rainbond/db/config"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"testing"
)
func TestAppRuntimeStore_GetTenantResource(t *testing.T) {
ocfg := option.Config{
DBType: "mysql",
MysqlConnectionInfo: "ree8Ai:Een3meeY@tcp(192.168.1.152:3306)/region",
EtcdEndPoints: []string{"http://192.168.1.152:2379"},
EtcdTimeout: 5,
KubeConfig: "/opt/rainbond/etc/kubernetes/kubecfg/admin.kubeconfig",
LeaderElectionNamespace: "rainbond",
}
dbconfig := config.Config{
DBType: ocfg.DBType,
MysqlConnectionInfo: ocfg.MysqlConnectionInfo,
EtcdEndPoints: ocfg.EtcdEndPoints,
EtcdTimeout: ocfg.EtcdTimeout,
}
//step 1:db manager init ,event log client init
if err := db.CreateManager(dbconfig); err != nil {
t.Fatalf("error creating db manager: %v", err)
}
defer db.CloseManager()
c, err := clientcmd.BuildConfigFromFlags("", ocfg.KubeConfig)
if err != nil {
t.Fatalf("read kube config file error: %v", err)
}
clientset, err := kubernetes.NewForConfig(c)
if err != nil {
t.Fatalf("create kube api client error: %v", err)
}
ocfg.KubeClient = clientset
startCh := channels.NewRingChannel(1024)
probeCh := channels.NewRingChannel(1024)
store := NewStore(clientset, db.GetManager(), ocfg, startCh, probeCh)
if err := store.Start(); err != nil {
t.Fatalf("error starting store: %v", err)
}
tenantID := "d22797956503441abce65e40705aac29"
resource := store.GetTenantResource(tenantID)
t.Logf("%+v",resource)
//t.Error("")
}

View File

@ -23,12 +23,11 @@ import (
"os"
"strconv"
"github.com/goodrain/rainbond/builder"
"github.com/Sirupsen/logrus"
"github.com/goodrain/rainbond/builder"
"github.com/goodrain/rainbond/db/model"
"github.com/goodrain/rainbond/event"
v1 "k8s.io/api/apps/v1"
"k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
)
@ -553,11 +552,15 @@ func (a *AppService) String() string {
//TenantResource tenant resource statistical models
type TenantResource struct {
TenantID string `json:"tenant_id,omitempty"`
CPURequest int64 `json:"cpu_request,omitempty"`
CPULimit int64 `json:"cpu_limit,omitempty"`
MemoryRequest int64 `json:"memory_request,omitempty"`
MemoryLimit int64 `json:"memory_limit,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
CPURequest int64 `json:"cpu_request,omitempty"`
CPULimit int64 `json:"cpu_limit,omitempty"`
MemoryRequest int64 `json:"memory_request,omitempty"`
MemoryLimit int64 `json:"memory_limit,omitempty"`
UnscdCPUReq int64 `json:"unscd_cpu_req,omitempty"`
UnscdCPULimit int64 `json:"unscd_cpu_limit,omitempty"`
UnscdMemoryReq int64 `json:"unscd_memory_req,omitempty"`
UnscdMemoryLimit int64 `json:"unscd_memory_limit,omitempty"`
}
// K8sResources holds kubernetes resources(svc, sercert, ep, ing).

View File

@ -538,6 +538,10 @@ type TenantResource struct {
MemoryRequest int64 `protobuf:"varint,3,opt,name=memory_request,json=memoryRequest,proto3" json:"memory_request,omitempty"`
MemoryLimit int64 `protobuf:"varint,4,opt,name=memory_limit,json=memoryLimit,proto3" json:"memory_limit,omitempty"`
RunningAppNum int64 `protobuf:"varint,5,opt,name=running_app_num,json=runningAppNum,proto3" json:"running_app_num,omitempty"`
UnscdCpuReq int64 `protobuf:"varint,6,opt,name=unscd_cpu_req,json=unscdCpuReq,proto3" json:"unscd_cpu_req,omitempty"`
UnscdCpuLimit int64 `protobuf:"varint,7,opt,name=unscd_cpu_limit,json=unscdCpuLimit,proto3" json:"unscd_cpu_limit,omitempty"`
UnscdMemoryReq int64 `protobuf:"varint,8,opt,name=unscd_memory_req,json=unscdMemoryReq,proto3" json:"unscd_memory_req,omitempty"`
UnscdMemoryLimit int64 `protobuf:"varint,9,opt,name=unscd_memory_limit,json=unscdMemoryLimit,proto3" json:"unscd_memory_limit,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -603,6 +607,34 @@ func (m *TenantResource) GetRunningAppNum() int64 {
return 0
}
func (m *TenantResource) GetUnscdCpuReq() int64 {
if m != nil {
return m.UnscdCpuReq
}
return 0
}
func (m *TenantResource) GetUnscdCpuLimit() int64 {
if m != nil {
return m.UnscdCpuLimit
}
return 0
}
func (m *TenantResource) GetUnscdMemoryReq() int64 {
if m != nil {
return m.UnscdMemoryReq
}
return 0
}
func (m *TenantResource) GetUnscdMemoryLimit() int64 {
if m != nil {
return m.UnscdMemoryLimit
}
return 0
}
type AddThirdPartyEndpointsReq struct {
Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"`
Sid string `protobuf:"bytes,2,opt,name=sid,proto3" json:"sid,omitempty"`
@ -941,73 +973,76 @@ func init() {
func init() { proto.RegisterFile("app_runtime_server.proto", fileDescriptor_f94cf1a886c479d6) }
var fileDescriptor_f94cf1a886c479d6 = []byte{
// 1044 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xef, 0x6e, 0xdb, 0x36,
0x10, 0xf7, 0xff, 0xd8, 0xe7, 0xd8, 0x69, 0xd8, 0xa5, 0x55, 0xdc, 0x76, 0x6d, 0x35, 0x74, 0xc8,
0x87, 0xc2, 0x1b, 0x32, 0x04, 0x4b, 0xd3, 0x62, 0x83, 0xd1, 0x04, 0x99, 0x81, 0xac, 0x0b, 0x94,
0xf4, 0xb3, 0xa1, 0x48, 0x6c, 0xc6, 0xc5, 0x22, 0x59, 0x91, 0x0a, 0xa0, 0x8f, 0xdb, 0x2b, 0xf4,
0x85, 0xf6, 0x04, 0xc3, 0x1e, 0x69, 0xe0, 0x1f, 0xc9, 0x92, 0xad, 0xa2, 0xf3, 0x36, 0x60, 0xdf,
0xa8, 0xdf, 0xdd, 0xef, 0x8e, 0x77, 0xa7, 0xbb, 0x23, 0x38, 0x3e, 0xe7, 0xb3, 0x38, 0xa1, 0x92,
0x44, 0x78, 0x26, 0x70, 0x7c, 0x8b, 0xe3, 0x31, 0x8f, 0x99, 0x64, 0xa8, 0xc1, 0xaf, 0xdc, 0x0d,
0x68, 0x9f, 0x44, 0x5c, 0xa6, 0xee, 0x57, 0x30, 0xbc, 0xc0, 0xf1, 0x2d, 0x09, 0xb0, 0x87, 0xdf,
0x27, 0x58, 0x48, 0xf4, 0x08, 0x40, 0x18, 0x64, 0x46, 0x42, 0xa7, 0xfe, 0xa4, 0xbe, 0xd7, 0xf3,
0x7a, 0x16, 0x99, 0x86, 0xee, 0x3e, 0x6c, 0x59, 0x82, 0xc8, 0x18, 0x8f, 0xa1, 0xbf, 0x60, 0x08,
0x4b, 0x81, 0x9c, 0x22, 0xdc, 0xe7, 0x30, 0xb8, 0xc4, 0xd4, 0xa7, 0x32, 0x63, 0x3c, 0x80, 0x9e,
0xd4, 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d, 0xf2, 0x64, 0x72, 0x6b, 0xe8, 0x05, 0x80, 0x61, 0xaa, 0x39, 0x85, 0x50, 0x81,
0x97, 0xd1, 0x76, 0x56, 0x96, 0xaf, 0x7a, 0x8e, 0xb8, 0x35, 0x74, 0x00, 0x83, 0x53, 0x2c, 0x0b,
0x3b, 0xac, 0x8a, 0x3d, 0x2c, 0xcf, 0x51, 0xb7, 0x86, 0x5e, 0xc1, 0xf6, 0x29, 0x96, 0x4b, 0x7d,
0xaa, 0xef, 0x56, 0x7a, 0x20, 0x8e, 0x50, 0x11, 0x32, 0x6a, 0x6e, 0x0d, 0xfd, 0x00, 0xf7, 0x95,
0xfb, 0xaa, 0x0c, 0x56, 0xb9, 0xbf, 0x5f, 0x9d, 0x48, 0xe1, 0xd6, 0xd0, 0x6b, 0xd8, 0xa9, 0xec,
0x34, 0xa4, 0x37, 0xc7, 0x47, 0x9b, 0x70, 0xd4, 0x53, 0x62, 0xf3, 0x72, 0xd6, 0x46, 0x2a, 0x3b,
0xc5, 0x18, 0xf9, 0x68, 0x13, 0xad, 0x18, 0xa9, 0xfc, 0xd5, 0x91, 0xdd, 0x61, 0xf3, 0xbf, 0x61,
0xe4, 0xaa, 0xa3, 0x5f, 0xf6, 0xdf, 0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa2, 0xcd, 0xa8, 0xa8,
0xf5, 0x0b, 0x00, 0x00,
// 1103 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x6d, 0x6f, 0xdb, 0x36,
0x10, 0xf6, 0xbb, 0xad, 0x73, 0xec, 0x26, 0xec, 0xd2, 0x2a, 0x6e, 0xbb, 0xb6, 0x1a, 0x3a, 0xe4,
0x43, 0xe0, 0x0d, 0x19, 0x82, 0xa5, 0x69, 0xb1, 0xc1, 0x48, 0x82, 0xcc, 0x40, 0xda, 0x05, 0x4a,
0xfa, 0xd9, 0x50, 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, 0x0d, 0xbd, 0x04, 0xd0, 0x4a, 0xd9, 0x4b, 0x11, 0x2a, 0xe8, 0x32, 0xd9, 0xf6, 0xca, 0x03,
0x41, 0x3e, 0x99, 0x9c, 0x1a, 0x3a, 0x80, 0xc1, 0x19, 0x16, 0x85, 0x39, 0x5b, 0xa5, 0x1e, 0x96,
0x7b, 0xbd, 0x53, 0x43, 0xaf, 0x61, 0xeb, 0x0c, 0x8b, 0xa5, 0x5e, 0xa2, 0xf6, 0x56, 0x7a, 0xc4,
0x8e, 0x50, 0x11, 0xd2, 0x34, 0xa7, 0x86, 0x7e, 0x80, 0x87, 0xd2, 0x7d, 0x55, 0x04, 0xab, 0xdc,
0x3f, 0xac, 0x0e, 0x24, 0x77, 0x6a, 0xe8, 0x18, 0xb6, 0x2b, 0x2b, 0x0d, 0xa9, 0xe9, 0xf6, 0xd1,
0x22, 0x1c, 0x59, 0x72, 0x59, 0xbf, 0xee, 0x95, 0x91, 0xca, 0x4a, 0xd1, 0x46, 0x3e, 0x5a, 0x44,
0x2b, 0x46, 0x2a, 0xaf, 0x3a, 0x32, 0x73, 0x76, 0xfe, 0x37, 0x8c, 0x5c, 0x77, 0xd4, 0xbf, 0x8f,
0x6f, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xab, 0x32, 0x17, 0x45, 0x99, 0x0c, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -69,6 +69,10 @@ message TenantResource {
int64 memory_request = 3;
int64 memory_limit = 4;
int64 running_app_num = 5;
int64 unscd_cpu_req = 6;
int64 unscd_cpu_limit = 7;
int64 unscd_memory_req = 8;
int64 unscd_memory_limit = 9;
}
message AddThirdPartyEndpointsReq {

View File

@ -21,8 +21,6 @@ package server
import (
"context"
"fmt"
"github.com/goodrain/rainbond/db/model"
corev1 "k8s.io/api/core/v1"
"net"
"strings"
"time"
@ -30,6 +28,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/eapache/channels"
"github.com/goodrain/rainbond/cmd/worker/option"
"github.com/goodrain/rainbond/db/model"
"github.com/goodrain/rainbond/discover.v2"
"github.com/goodrain/rainbond/util"
"github.com/goodrain/rainbond/worker/appm/store"
@ -38,6 +37,7 @@ import (
"github.com/goodrain/rainbond/worker/server/pb"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
corev1 "k8s.io/api/core/v1"
)
//RuntimeServer app runtime grpc server
@ -115,6 +115,10 @@ func (r *RuntimeServer) GetTenantResource(ctx context.Context, re *pb.TenantRequ
tr.CpuRequest = res.CPURequest
tr.MemoryLimit = res.MemoryLimit / 1024 / 1024
tr.MemoryRequest = res.MemoryRequest / 1024 / 1024
tr.UnscdCpuLimit = res.UnscdCPULimit
tr.UnscdCpuReq = res.UnscdCPUReq
tr.UnscdMemoryLimit = res.UnscdMemoryLimit / 1024 / 1024
tr.UnscdMemoryReq = res.UnscdMemoryReq / 1024 / 1024
return &tr, nil
}