mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 18:58:02 +08:00
commit
b85f086d55
11
Makefile
11
Makefile
@ -41,16 +41,7 @@ binary:
|
||||
run-c:image
|
||||
test/run/run_${WHAT}.sh
|
||||
run:build
|
||||
ifeq ($(WHAT),api)
|
||||
${BIN_PATH}/${BASE_NAME}-api --log-level=debug \
|
||||
--mysql="root:@tcp(127.0.0.1:3306)/region" \
|
||||
--kube-config="`PWD`/test/admin.kubeconfig" \
|
||||
--api-ssl-enable=true \
|
||||
--client-ca-file="`PWD`/test/ssl/ca.pem" \
|
||||
--api-ssl-certfile="`PWD`/test/ssl/server.pem" \
|
||||
--api-ssl-keyfile="`PWD`/test/ssl/server.key.pem"
|
||||
--etcd=http://127.0.0.1:4001,http://127.0.0.1:2379
|
||||
else ifeq ($(WHAT),mq)
|
||||
ifeq ($(WHAT),mq)
|
||||
${BIN_PATH}/${BASE_NAME}-mq --log-level=debug
|
||||
else ifeq ($(WHAT),worker)
|
||||
test/run/run_worker.sh ${BIN_PATH}/${BASE_NAME}-worker
|
||||
|
@ -35,7 +35,8 @@ type TenantHandler interface {
|
||||
StatsMemCPU(services []*dbmodel.TenantServices) (*api_model.StatsInfo, error)
|
||||
TotalMemCPU(services []*dbmodel.TenantServices) (*api_model.StatsInfo, error)
|
||||
GetTenantsResources(tr *api_model.TenantResources) (map[string]map[string]interface{}, error)
|
||||
GetAllocatableResources() (int64, int64, error)
|
||||
GetTenantResource(tenantID string) (TenantResourceStats, error)
|
||||
GetAllocatableResources() (*ClusterResourceStats, error)
|
||||
GetServicesResources(tr *api_model.ServicesResources) (map[string]map[string]interface{}, error)
|
||||
TenantsSum() (int, error)
|
||||
GetProtocols() ([]*dbmodel.RegionProcotols, *util.APIHandleError)
|
||||
|
@ -20,13 +20,14 @@ package cloud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/goodrain/rainbond/api/handler"
|
||||
"github.com/goodrain/rainbond/db"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/goodrain/rainbond/api/handler"
|
||||
"github.com/goodrain/rainbond/db"
|
||||
|
||||
"github.com/pquerna/ffjson/ffjson"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
@ -72,64 +73,27 @@ func PubChargeSverify(tenant *model.Tenants, quantity int, reason string) *util.
|
||||
|
||||
// PriChargeSverify verifies that the resources requested in the private cloud are legal
|
||||
func PriChargeSverify(tenant *model.Tenants, quantity int) *util.APIHandleError {
|
||||
svcs, err := db.GetManager().TenantServiceDao().GetServicesByTenantID(tenant.UUID)
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting tenant: %v", err)
|
||||
return util.CreateAPIHandleError(500, fmt.Errorf("error getting tenant: %v", err))
|
||||
}
|
||||
var svcids []string
|
||||
svcMap := make(map[string]*model.TenantServices)
|
||||
for _, svc := range svcs {
|
||||
svcids = append(svcids, svc.ServiceID)
|
||||
svcMap[svc.ServiceID] = svc
|
||||
}
|
||||
// get services status
|
||||
var usedMem int
|
||||
if len(svcids) > 0 {
|
||||
ss := handler.GetTenantManager().GetServicesStatus(strings.Join(svcids, ","))
|
||||
for k, v := range ss {
|
||||
if !handler.GetTenantManager().IsClosedStatus(v) {
|
||||
if svc, ok := svcMap[k]; ok {
|
||||
usedMem += svc.ContainerMemory * svc.Replicas
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t, err := db.GetManager().TenantDao().GetTenantByUUID(tenant.UUID)
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting tenant: %v", err)
|
||||
return util.CreateAPIHandleError(500, fmt.Errorf("error getting tenant: %v", err))
|
||||
}
|
||||
availMem := int64(t.LimitMemory)
|
||||
|
||||
if availMem == 0 {
|
||||
_, allMem, err := handler.GetTenantManager().GetAllocatableResources()
|
||||
if t.LimitMemory == 0 {
|
||||
clusterStats, err := handler.GetTenantManager().GetAllocatableResources()
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting allocatable resources: %v", err)
|
||||
return util.CreateAPIHandleError(500, fmt.Errorf("error getting allocatable resources: %v", err))
|
||||
}
|
||||
availMem = allMem - int64(usedMem)
|
||||
|
||||
tenants, err := db.GetManager().TenantDao().GetALLTenants()
|
||||
if err != nil {
|
||||
logrus.Errorf("error getting all tenants: %v", err)
|
||||
return util.CreateAPIHandleError(500, fmt.Errorf("error getting all tenants: %v", err))
|
||||
}
|
||||
for _, item := range tenants {
|
||||
availMem = availMem - int64(item.LimitMemory)
|
||||
}
|
||||
availMem := clusterStats.AllMemory - clusterStats.RequestMemory
|
||||
if availMem >= int64(quantity) {
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("success"))
|
||||
} else {
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("cluster_lack_of_memory"))
|
||||
}
|
||||
} else {
|
||||
availMem = availMem - int64(usedMem)
|
||||
if availMem >= int64(quantity) {
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("success"))
|
||||
} else {
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("lack_of_memory"))
|
||||
}
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("cluster_lack_of_memory"))
|
||||
}
|
||||
tenantStas, err := handler.GetTenantManager().GetTenantResource(tenant.UUID)
|
||||
availMem := int64(t.LimitMemory) - tenantStas.MemoryRequest
|
||||
if availMem >= int64(quantity) {
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("success"))
|
||||
}
|
||||
return util.CreateAPIHandleError(200, fmt.Errorf("lack_of_memory"))
|
||||
}
|
||||
|
@ -22,13 +22,14 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/goodrain/rainbond/api/proxy"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/goodrain/rainbond/api/proxy"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
api_model "github.com/goodrain/rainbond/api/model"
|
||||
@ -702,32 +703,28 @@ func (s *ServiceAction) GetPagedTenantRes(offset, len int) ([]*api_model.TenantR
|
||||
|
||||
//GetTenantRes get pagedTenantServiceRes(s)
|
||||
func (s *ServiceAction) GetTenantRes(uuid string) (*api_model.TenantResource, error) {
|
||||
tenant, err := db.GetManager().TenantDao().GetTenantByUUID(uuid)
|
||||
if err != nil {
|
||||
logrus.Errorf("get tenant %s info failure %v", uuid, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
services, err := db.GetManager().TenantServiceDao().GetServicesByTenantID(uuid)
|
||||
if err != nil {
|
||||
logrus.Errorf("get service by id error, %v, %v", services, err)
|
||||
logrus.Errorf("get service by id error, %v, %v", services, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
var serviceIDs string
|
||||
var AllocatedCPU, AllocatedMEM int
|
||||
var serMap = make(map[string]*dbmodel.TenantServices, len(services))
|
||||
for _, ser := range services {
|
||||
if serviceIDs == "" {
|
||||
serviceIDs += ser.ServiceID
|
||||
} else {
|
||||
serviceIDs += "," + ser.ServiceID
|
||||
}
|
||||
AllocatedCPU += ser.ContainerCPU
|
||||
AllocatedMEM += ser.ContainerMemory
|
||||
serMap[ser.ServiceID] = ser
|
||||
}
|
||||
status := s.statusCli.GetStatuss(serviceIDs)
|
||||
var UsedCPU, UsedMEM int
|
||||
for k, v := range status {
|
||||
if !s.statusCli.IsClosedStatus(v) {
|
||||
UsedCPU += serMap[k].ContainerCPU
|
||||
UsedMEM += serMap[k].ContainerMemory
|
||||
}
|
||||
AllocatedCPU += ser.ContainerCPU * ser.Replicas
|
||||
AllocatedMEM += ser.ContainerMemory * ser.Replicas
|
||||
}
|
||||
tenantResUesd, _ := s.statusCli.GetTenantResource(uuid)
|
||||
disks := GetServicesDisk(strings.Split(serviceIDs, ","), GetPrometheusProxy())
|
||||
var value float64
|
||||
for _, v := range disks {
|
||||
@ -735,12 +732,12 @@ func (s *ServiceAction) GetTenantRes(uuid string) (*api_model.TenantResource, er
|
||||
}
|
||||
var res api_model.TenantResource
|
||||
res.UUID = uuid
|
||||
res.Name = ""
|
||||
res.EID = ""
|
||||
res.Name = tenant.Name
|
||||
res.EID = tenant.EID
|
||||
res.AllocatedCPU = AllocatedCPU
|
||||
res.AllocatedMEM = AllocatedMEM
|
||||
res.UsedCPU = UsedCPU
|
||||
res.UsedMEM = UsedMEM
|
||||
res.UsedCPU = int(tenantResUesd.CpuRequest)
|
||||
res.UsedMEM = int(tenantResUesd.MemoryRequest)
|
||||
res.UsedDisk = value
|
||||
return &res, nil
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ package handler
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/goodrain/rainbond/cmd/api/option"
|
||||
"net/http"
|
||||
"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"
|
||||
@ -171,76 +172,34 @@ func (t *TenantAction) GetTenantsResources(tr *api_model.TenantResources) (map[s
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var serviceTenantCount = make(map[string]int, len(ids))
|
||||
for _, s := range services {
|
||||
serviceTenantCount[s.TenantID]++
|
||||
}
|
||||
// get cluster resources
|
||||
allCPU, allMem, err := t.GetAllocatableResources()
|
||||
clusterStats, err := t.GetAllocatableResources()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting allocatalbe cpu and memory: %v", err)
|
||||
}
|
||||
|
||||
var serviceIDs []string
|
||||
var serviceMap = make(map[string]dbmodel.TenantServices, len(services))
|
||||
var serviceTenantRunning = make(map[string]int, len(ids))
|
||||
var serviceTenantCount = make(map[string]int, len(ids))
|
||||
serviceStatus := t.statusCli.GetAllStatus()
|
||||
for _, s := range services {
|
||||
serviceIDs = append(serviceIDs, s.ServiceID)
|
||||
serviceMap[s.ServiceID] = *s
|
||||
if !t.statusCli.IsClosedStatus(serviceStatus[s.ServiceID]) {
|
||||
serviceTenantRunning[s.TenantID]++
|
||||
}
|
||||
serviceTenantCount[s.TenantID]++
|
||||
}
|
||||
var allocatedMemory int64
|
||||
for _, v := range limits {
|
||||
allocatedMemory = allocatedMemory + int64(v)
|
||||
}
|
||||
allMem = allMem - allocatedMemory
|
||||
var result = make(map[string]map[string]interface{}, len(ids))
|
||||
for k, v := range limits {
|
||||
result[k] = map[string]interface{}{
|
||||
"tenant_id": k,
|
||||
"limit_memory": v,
|
||||
"service_running_num": serviceTenantRunning[k],
|
||||
"service_total_num": serviceTenantCount[k],
|
||||
"limit_cpu": v / 4,
|
||||
"cpu": 0,
|
||||
"memory": 0,
|
||||
for _, tenantID := range ids {
|
||||
tr, _ := t.statusCli.GetTenantResource(tenantID)
|
||||
var limitMemory int64
|
||||
if l, ok := limits[tenantID]; ok && l != 0 {
|
||||
limitMemory = int64(l)
|
||||
} else {
|
||||
limitMemory = clusterStats.AllMemory
|
||||
}
|
||||
result[tenantID] = map[string]interface{}{
|
||||
"tenant_id": tenantID,
|
||||
"limit_memory": limitMemory,
|
||||
"limit_cpu": clusterStats.AllCPU,
|
||||
"service_running_num": tr.RunningAppNum,
|
||||
"service_total_num": serviceTenantCount[tenantID],
|
||||
"cpu": tr.CpuRequest,
|
||||
"memory": tr.MemoryRequest,
|
||||
"disk": 0,
|
||||
}
|
||||
if v == 0 {
|
||||
result[k]["limit_memory"] = allMem
|
||||
if allMem/4 > allCPU {
|
||||
result[k]["limit_cpu"] = allCPU
|
||||
} else {
|
||||
result[k]["limit_cpu"] = allMem / 4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status := t.statusCli.GetStatuss(strings.Join(serviceIDs, ","))
|
||||
for k, v := range status {
|
||||
if _, ok := serviceMap[k]; !ok {
|
||||
continue
|
||||
}
|
||||
if _, ok := result[serviceMap[k].TenantID]; !ok {
|
||||
result[serviceMap[k].TenantID] = map[string]interface{}{
|
||||
"tenant_id": k,
|
||||
"limit_memory": allMem,
|
||||
"limit_cpu": allMem / 4,
|
||||
"cpu": 0,
|
||||
"memory": 0,
|
||||
"disk": 0,
|
||||
}
|
||||
if allMem/4 > allCPU {
|
||||
result[serviceMap[k].TenantID]["limit_cpu"] = allCPU
|
||||
}
|
||||
}
|
||||
if !t.statusCli.IsClosedStatus(v) {
|
||||
result[serviceMap[k].TenantID]["cpu"] = result[serviceMap[k].TenantID]["cpu"].(int) +
|
||||
(serviceMap[k].ContainerCPU * serviceMap[k].Replicas)
|
||||
result[serviceMap[k].TenantID]["memory"] = result[serviceMap[k].TenantID]["memory"].(int) +
|
||||
(serviceMap[k].ContainerMemory * serviceMap[k].Replicas)
|
||||
}
|
||||
}
|
||||
//query disk used in prometheus
|
||||
pproxy := GetPrometheusProxy()
|
||||
@ -282,24 +241,56 @@ func (t *TenantAction) GetTenantsResources(tr *api_model.TenantResources) (map[s
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetAllocatableResources returns allocatable cpu and memory
|
||||
func (t *TenantAction) GetAllocatableResources() (int64, int64, error) {
|
||||
var allCPU int64 // allocatable CPU
|
||||
var allMem int64 // allocatable memory
|
||||
//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"`
|
||||
}
|
||||
|
||||
//GetTenantResource get tenant resource
|
||||
func (t *TenantAction) GetTenantResource(tenantID string) (ts TenantResourceStats, err error) {
|
||||
tr, err := t.statusCli.GetTenantResource(tenantID)
|
||||
if err != nil {
|
||||
return ts, err
|
||||
}
|
||||
ts.TenantID = tenantID
|
||||
ts.CPULimit = tr.CpuLimit
|
||||
ts.CPURequest = tr.CpuRequest
|
||||
ts.MemoryLimit = tr.MemoryLimit
|
||||
ts.MemoryRequest = tr.MemoryRequest
|
||||
ts.RunningAppNum = tr.RunningAppNum
|
||||
return
|
||||
}
|
||||
|
||||
//ClusterResourceStats cluster resource stats
|
||||
type ClusterResourceStats struct {
|
||||
AllCPU int64
|
||||
AllMemory int64
|
||||
RequestCPU int64
|
||||
RequestMemory int64
|
||||
}
|
||||
|
||||
// GetAllocatableResources returns allocatable cpu and memory (MB)
|
||||
func (t *TenantAction) GetAllocatableResources() (*ClusterResourceStats, error) {
|
||||
var crs ClusterResourceStats
|
||||
nproxy := GetNodeProxy()
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/v2/nodes/rule/compute",
|
||||
t.OptCfg.NodeAPI), nil)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("error creating http request: %v", err)
|
||||
return &crs, fmt.Errorf("error creating http request: %v", err)
|
||||
}
|
||||
resp, err := nproxy.Do(req)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("error getting cluster resources: %v", err)
|
||||
return &crs, fmt.Errorf("error getting cluster resources: %v", err)
|
||||
}
|
||||
if resp.Body != nil {
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return 0, 0, fmt.Errorf("error getting cluster resources: status code: %d; "+
|
||||
return &crs, fmt.Errorf("error getting cluster resources: status code: %d; "+
|
||||
"response: %v", resp.StatusCode, resp)
|
||||
}
|
||||
type foo struct {
|
||||
@ -308,27 +299,25 @@ func (t *TenantAction) GetAllocatableResources() (int64, int64, error) {
|
||||
var f foo
|
||||
err = json.NewDecoder(resp.Body).Decode(&f)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("error decoding response body: %v", err)
|
||||
return &crs, fmt.Errorf("error decoding response body: %v", err)
|
||||
}
|
||||
|
||||
for _, n := range f.List {
|
||||
if n.Status != "running" {
|
||||
logrus.Warningf("node %s isn't running, ignore it", n.ID)
|
||||
continue
|
||||
}
|
||||
if k := n.NodeStatus.KubeNode; k != nil {
|
||||
if k := n.NodeStatus.KubeNode; k != nil && !k.Spec.Unschedulable {
|
||||
s := strings.Replace(k.Status.Allocatable.Cpu().String(), "m", "", -1)
|
||||
i, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("error converting string to int64: %v", err)
|
||||
return &crs, fmt.Errorf("error converting string to int64: %v", err)
|
||||
}
|
||||
allCPU = allCPU + i
|
||||
allMem = allMem + k.Status.Allocatable.Memory().Value()/(1024*1024)
|
||||
crs.AllCPU += i
|
||||
crs.AllMemory += k.Status.Allocatable.Memory().Value() / (1024 * 1024)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allCPU, allMem, nil
|
||||
ts, _ := t.statusCli.GetTenantResource("")
|
||||
crs.RequestCPU = ts.CpuRequest
|
||||
crs.RequestMemory = ts.MemoryRequest
|
||||
return &crs, nil
|
||||
}
|
||||
|
||||
//GetServicesResources Gets the resource usage of the specified service.
|
||||
|
@ -27,17 +27,21 @@ type PagedTenantResList struct {
|
||||
Length int `json:"length"`
|
||||
}
|
||||
|
||||
//TenantResource path参数
|
||||
//TenantResource tenant resource
|
||||
//swagger:parameters getVolumes getDepVolumes
|
||||
type TenantResource struct {
|
||||
AllocatedCPU int `json:"alloc_cpu"`
|
||||
AllocatedMEM int `json:"alloc_memory"`
|
||||
UsedCPU int `json:"used_cpu"`
|
||||
UsedMEM int `json:"used_memory"`
|
||||
UsedDisk float64 `json:"used_disk"`
|
||||
Name string `json:"name"`
|
||||
UUID string `json:"uuid"`
|
||||
EID string `json:"eid"`
|
||||
//without plugin
|
||||
AllocatedCPU int `json:"alloc_cpu"`
|
||||
//without plugin
|
||||
AllocatedMEM int `json:"alloc_memory"`
|
||||
//with plugin
|
||||
UsedCPU int `json:"used_cpu"`
|
||||
//with plugin
|
||||
UsedMEM int `json:"used_memory"`
|
||||
UsedDisk float64 `json:"used_disk"`
|
||||
Name string `json:"name"`
|
||||
UUID string `json:"uuid"`
|
||||
EID string `json:"eid"`
|
||||
}
|
||||
|
||||
func (list TenantResList) Len() int {
|
||||
|
@ -135,21 +135,26 @@ func (n *node) GetAllNodeHealth() (map[string][]map[string]string, *util.APIHand
|
||||
return gc, nil
|
||||
}
|
||||
|
||||
func (n *node) Add(node *client.APIHostNode) *util.APIHandleError {
|
||||
func (n *node) Add(node *client.APIHostNode) (*client.HostNode, *util.APIHandleError) {
|
||||
body, err := json.Marshal(node)
|
||||
if err != nil {
|
||||
return util.CreateAPIHandleError(400, err)
|
||||
return nil, util.CreateAPIHandleError(400, err)
|
||||
}
|
||||
var res utilhttp.ResponseBody
|
||||
var renode client.HostNode
|
||||
res.Bean = &renode
|
||||
code, err := n.DoRequest(n.prefix, "POST", bytes.NewBuffer(body), &res)
|
||||
if err != nil {
|
||||
return util.CreateAPIHandleError(code, err)
|
||||
return nil, util.CreateAPIHandleError(code, err)
|
||||
}
|
||||
return handleAPIResult(code, res)
|
||||
return &renode, handleAPIResult(code, res)
|
||||
}
|
||||
func (n *node) Label(nid string) NodeLabelInterface {
|
||||
return &nodeLabelImpl{nodeImpl: n, NodeID: nid}
|
||||
}
|
||||
func (n *node) Condition(nid string) NodeConditionInterface {
|
||||
return &nodeConditionImpl{nodeImpl: n, NodeID: nid}
|
||||
}
|
||||
|
||||
type nodeLabelImpl struct {
|
||||
nodeImpl *node
|
||||
@ -205,6 +210,32 @@ func (nl *nodeLabelImpl) Add(k, v string) *util.APIHandleError {
|
||||
return nil
|
||||
}
|
||||
|
||||
type nodeConditionImpl struct {
|
||||
nodeImpl *node
|
||||
NodeID string
|
||||
}
|
||||
|
||||
func (nl *nodeConditionImpl) List() ([]client.NodeCondition, *util.APIHandleError) {
|
||||
var decode []client.NodeCondition
|
||||
var res utilhttp.ResponseBody
|
||||
res.List = &decode
|
||||
code, err := nl.nodeImpl.DoRequest(nl.nodeImpl.prefix+"/"+nl.NodeID+"/conditions", "GET", nil, &res)
|
||||
if err != nil || code != 200 {
|
||||
return nil, util.CreateAPIHandleError(code, err)
|
||||
}
|
||||
return decode, nil
|
||||
}
|
||||
func (nl *nodeConditionImpl) Delete(k client.NodeConditionType) ([]client.NodeCondition, *util.APIHandleError) {
|
||||
var decode []client.NodeCondition
|
||||
var res utilhttp.ResponseBody
|
||||
res.List = &decode
|
||||
code, err := nl.nodeImpl.DoRequest(nl.nodeImpl.prefix+"/"+nl.NodeID+"/conditions/"+string(k), "DELETE", nil, &res)
|
||||
if err != nil || code != 200 {
|
||||
return nil, util.CreateAPIHandleError(code, err)
|
||||
}
|
||||
return decode, nil
|
||||
}
|
||||
|
||||
func (n *node) Delete(nid string) *util.APIHandleError {
|
||||
code, err := n.DoRequest(n.prefix+"/"+nid, "DELETE", nil, nil)
|
||||
if err != nil {
|
||||
@ -305,13 +336,14 @@ type NodeInterface interface {
|
||||
GetNodeResource(node string) (*client.NodePodResource, *util.APIHandleError)
|
||||
List() ([]*client.HostNode, *util.APIHandleError)
|
||||
GetAllNodeHealth() (map[string][]map[string]string, *util.APIHandleError)
|
||||
Add(node *client.APIHostNode) *util.APIHandleError
|
||||
Add(node *client.APIHostNode) (*client.HostNode, *util.APIHandleError)
|
||||
Up(nid string) *util.APIHandleError
|
||||
Down(nid string) *util.APIHandleError
|
||||
UnSchedulable(nid string) *util.APIHandleError
|
||||
ReSchedulable(nid string) *util.APIHandleError
|
||||
Delete(nid string) *util.APIHandleError
|
||||
Label(nid string) NodeLabelInterface
|
||||
Condition(nid string) NodeConditionInterface
|
||||
Install(nid string) *util.APIHandleError
|
||||
UpdateNodeStatus(nid, status string) (*client.HostNode, *util.APIHandleError)
|
||||
}
|
||||
@ -323,6 +355,12 @@ type NodeLabelInterface interface {
|
||||
List() (map[string]string, *util.APIHandleError)
|
||||
}
|
||||
|
||||
//NodeConditionInterface node condition manage api
|
||||
type NodeConditionInterface interface {
|
||||
List() ([]client.NodeCondition, *util.APIHandleError)
|
||||
Delete(conditionType client.NodeConditionType) ([]client.NodeCondition, *util.APIHandleError)
|
||||
}
|
||||
|
||||
//ConfigsInterface 数据中心配置API
|
||||
type ConfigsInterface interface {
|
||||
Get() (*model.GlobalConfig, *util.APIHandleError)
|
||||
|
@ -157,10 +157,10 @@ func (m *Manager) Run() {
|
||||
websocketRouter.Mount("/logs", websocket.LogRoutes())
|
||||
websocketRouter.Mount("/app", websocket.AppRoutes())
|
||||
if m.conf.WebsocketSSL {
|
||||
logrus.Infof("websocket listen on (HTTPs) 0.0.0.0%v", m.conf.WebsocketAddr)
|
||||
logrus.Infof("websocket listen on (HTTPs) %s", m.conf.WebsocketAddr)
|
||||
logrus.Fatal(http.ListenAndServeTLS(m.conf.WebsocketAddr, m.conf.WebsocketCertFile, m.conf.WebsocketKeyFile, websocketRouter))
|
||||
} else {
|
||||
logrus.Infof("websocket listen on (HTTP) 0.0.0.0%v", m.conf.WebsocketAddr)
|
||||
logrus.Infof("websocket listen on (HTTP) %s", m.conf.WebsocketAddr)
|
||||
logrus.Fatal(http.ListenAndServe(m.conf.WebsocketAddr, websocketRouter))
|
||||
}
|
||||
}()
|
||||
@ -181,11 +181,11 @@ func (m *Manager) Run() {
|
||||
ClientAuth: tls.RequireAndVerifyClientCert,
|
||||
},
|
||||
}
|
||||
logrus.Infof("api listen on (HTTPs) 0.0.0.0%v", m.conf.APIAddrSSL)
|
||||
logrus.Infof("api listen on (HTTPs) %s", m.conf.APIAddrSSL)
|
||||
logrus.Fatal(s.ListenAndServeTLS(m.conf.APICertFile, m.conf.APIKeyFile))
|
||||
}()
|
||||
}
|
||||
logrus.Infof("api listen on (HTTP) 0.0.0.0%v", m.conf.APIAddr)
|
||||
logrus.Infof("api listen on (HTTP) %s", m.conf.APIAddr)
|
||||
logrus.Fatal(http.ListenAndServe(m.conf.APIAddr, m.r))
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ func (a *APIServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&a.DBType, "db-type", "mysql", "db type mysql or etcd")
|
||||
fs.StringVar(&a.DBConnectionInfo, "mysql", "admin:admin@tcp(127.0.0.1:3306)/region", "mysql db connection info")
|
||||
fs.StringVar(&a.APIAddr, "api-addr", "127.0.0.1:8888", "the api server listen address")
|
||||
fs.StringVar(&a.APIAddrSSL, "api-addr-ssl", ":8443", "the api server listen address")
|
||||
fs.StringVar(&a.WebsocketAddr, "ws-addr", ":6060", "the websocket server listen address")
|
||||
fs.StringVar(&a.APIAddrSSL, "api-addr-ssl", "0.0.0.0:8443", "the api server listen address")
|
||||
fs.StringVar(&a.WebsocketAddr, "ws-addr", "0.0.0.0:6060", "the websocket server listen address")
|
||||
fs.BoolVar(&a.APISSL, "api-ssl-enable", false, "whether to enable websocket SSL")
|
||||
fs.StringVar(&a.APICaFile, "client-ca-file", "", "api ssl ca file")
|
||||
fs.StringVar(&a.APICertFile, "api-ssl-certfile", "", "api ssl cert file")
|
||||
|
@ -50,6 +50,11 @@ func showError(m string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func showSuccessMsg(m string) {
|
||||
fmt.Printf("Success: %s\n", m)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
//NewCmdShow show
|
||||
func NewCmdShow() cli.Command {
|
||||
c := cli.Command{
|
||||
@ -143,9 +148,8 @@ func handleStatus(serviceTable *termtables.Table, v *client.HostNode) {
|
||||
serviceTable.AddRow(v.ID, v.InternalIP, v.HostName, v.Role.String(), v.Mode, getStatusShow(v))
|
||||
}
|
||||
|
||||
func handleResult(serviceTable *termtables.Table, v *client.HostNode) {
|
||||
|
||||
for _, v := range v.NodeStatus.Conditions {
|
||||
func handleConditionResult(serviceTable *termtables.Table, conditions []client.NodeCondition) {
|
||||
for _, v := range conditions {
|
||||
if v.Type == client.NodeReady {
|
||||
continue
|
||||
}
|
||||
@ -167,8 +171,8 @@ func handleResult(serviceTable *termtables.Table, v *client.HostNode) {
|
||||
}
|
||||
}
|
||||
|
||||
func extractReady(serviceTable *termtables.Table, v *client.HostNode, name string) {
|
||||
for _, v := range v.NodeStatus.Conditions {
|
||||
func extractReady(serviceTable *termtables.Table, conditions []client.NodeCondition, name string) {
|
||||
for _, v := range conditions {
|
||||
if string(v.Type) == name {
|
||||
var formatReady string
|
||||
if v.Status == client.ConditionFalse {
|
||||
@ -244,8 +248,8 @@ func NewCmdNode() cli.Command {
|
||||
fmt.Printf("-------------------Service health-----------------------\n")
|
||||
serviceTable := termtables.CreateTable()
|
||||
serviceTable.AddHeaders("Condition", "Result", "Message")
|
||||
extractReady(serviceTable, v, "Ready")
|
||||
handleResult(serviceTable, v)
|
||||
extractReady(serviceTable, v.NodeStatus.Conditions, "Ready")
|
||||
handleConditionResult(serviceTable, v.NodeStatus.Conditions)
|
||||
fmt.Println(serviceTable.Render())
|
||||
return nil
|
||||
},
|
||||
@ -486,6 +490,77 @@ func NewCmdNode() cli.Command {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "condition",
|
||||
Usage: "handle node conditions, support delete and list",
|
||||
Subcommands: []cli.Command{
|
||||
cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "delete condition for the specified node",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "name,n",
|
||||
Value: "",
|
||||
Usage: "the condition type name",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
Common(c)
|
||||
hostID := c.Args().First()
|
||||
if hostID == "" {
|
||||
logrus.Errorf("need hostID")
|
||||
return nil
|
||||
}
|
||||
conditionType := c.String("name")
|
||||
_, err := clients.RegionClient.Nodes().Condition(hostID).Delete(client.NodeConditionType(conditionType))
|
||||
handleErr(err)
|
||||
showSuccessMsg("delete condition success")
|
||||
return nil
|
||||
},
|
||||
},
|
||||
cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list the conditions of the specified node",
|
||||
Action: func(c *cli.Context) error {
|
||||
Common(c)
|
||||
hostID := c.Args().First()
|
||||
if hostID == "" {
|
||||
logrus.Errorf("need hostID")
|
||||
return nil
|
||||
}
|
||||
conditions, err := clients.RegionClient.Nodes().Condition(hostID).List()
|
||||
handleErr(err)
|
||||
serviceTable := termtables.CreateTable()
|
||||
serviceTable.AddHeaders("Condition", "Result", "Message")
|
||||
handleConditionResult(serviceTable, conditions)
|
||||
fmt.Println(serviceTable.Render())
|
||||
return nil
|
||||
},
|
||||
},
|
||||
cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list the label of the specified node",
|
||||
Flags: []cli.Flag{},
|
||||
Action: func(c *cli.Context) error {
|
||||
Common(c)
|
||||
hostID := c.Args().First()
|
||||
if hostID == "" {
|
||||
logrus.Errorf("need hostID")
|
||||
return nil
|
||||
}
|
||||
labels, err := clients.RegionClient.Nodes().Label(hostID).List()
|
||||
handleErr(err)
|
||||
labelTable := termtables.CreateTable()
|
||||
labelTable.AddHeaders("LableKey", "LableValue")
|
||||
for k, v := range labels {
|
||||
labelTable.AddRow(k, v)
|
||||
}
|
||||
fmt.Print(labelTable.Render())
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "add",
|
||||
Usage: "Add a node into the cluster",
|
||||
@ -548,12 +623,11 @@ func NewCmdNode() cli.Command {
|
||||
node.Privatekey = c.String("private-key")
|
||||
node.AutoInstall = false
|
||||
node.ID = c.String("id")
|
||||
err := clients.RegionClient.Nodes().Add(&node)
|
||||
renode, err := clients.RegionClient.Nodes().Add(&node)
|
||||
handleErr(err)
|
||||
if c.Bool("install") {
|
||||
node, err := clients.RegionClient.Nodes().Get(node.ID)
|
||||
handleErr(err)
|
||||
installNode(node)
|
||||
installNode(renode)
|
||||
} else {
|
||||
fmt.Println("success add node, you install it by running: grctl node install <nodeID>")
|
||||
}
|
||||
|
@ -288,6 +288,40 @@ func GetLabel(w http.ResponseWriter, r *http.Request) {
|
||||
httputil.ReturnSuccess(r, w, node.Labels)
|
||||
}
|
||||
|
||||
//ListNodeCondition list node condition
|
||||
func ListNodeCondition(w http.ResponseWriter, r *http.Request) {
|
||||
nodeUID := strings.TrimSpace(chi.URLParam(r, "node_id"))
|
||||
node, err := nodeService.GetNode(nodeUID)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, node.NodeStatus.Conditions)
|
||||
}
|
||||
|
||||
//DeleteNodeCondition delete node condition
|
||||
func DeleteNodeCondition(w http.ResponseWriter, r *http.Request) {
|
||||
nodeUID := strings.TrimSpace(chi.URLParam(r, "node_id"))
|
||||
conditionType := strings.TrimSpace(chi.URLParam(r, "condition"))
|
||||
node, err := nodeService.GetNode(nodeUID)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
for _, condition := range node.NodeStatus.Conditions {
|
||||
if string(condition.Type) == conditionType {
|
||||
node, err := nodeService.DeleteNodeCondition(nodeUID, condition.Type)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, node.NodeStatus.Conditions)
|
||||
return
|
||||
}
|
||||
}
|
||||
httputil.ReturnError(r, w, 404, "condition not exist")
|
||||
}
|
||||
|
||||
//DownNode 节点下线,计算节点操作
|
||||
func DownNode(w http.ResponseWriter, r *http.Request) {
|
||||
nodeUID := strings.TrimSpace(chi.URLParam(r, "node_id"))
|
||||
|
@ -73,7 +73,6 @@ func Routers(mode string) *chi.Mux {
|
||||
r.Get("/", controller.GetNodes)
|
||||
r.Get("/all_node_health", controller.GetAllNodeHealth)
|
||||
r.Get("/rule/{rule}", controller.GetRuleNodes)
|
||||
|
||||
r.Get("/{node_id}", controller.GetNode)
|
||||
r.Put("/{node_id}/status", controller.UpdateNodeStatus)
|
||||
r.Put("/{node_id}/unschedulable", controller.Cordon)
|
||||
@ -85,6 +84,8 @@ func Routers(mode string) *chi.Mux {
|
||||
r.Get("/{node_id}/instance", controller.Instances)
|
||||
r.Get("/{node_id}/check", controller.CheckNode)
|
||||
r.Get("/{node_id}/resource", controller.Resource)
|
||||
r.Get("/{node_id}/conditions", controller.ListNodeCondition)
|
||||
r.Delete("/{node_id}/conditions/{condition}", controller.DeleteNodeCondition)
|
||||
// about node install
|
||||
r.Post("/{node_id}/install", controller.InstallNode) //install node
|
||||
r.Post("/", controller.AddNode) //add node
|
||||
|
@ -392,15 +392,6 @@ func (n *NodeService) GetNodeResource(nodeUID string) (*model.NodePodResource, *
|
||||
rm := v.Resources.Requests.Memory().Value()
|
||||
memRequest += rm
|
||||
}
|
||||
//lc := v.Spec.Containers[0].Resources.Limits.Cpu().MilliValue()
|
||||
//cpuLimit += lc
|
||||
//lm := v.Spec.Containers[0].Resources.Limits.Memory().Value()
|
||||
//memLimit += lm
|
||||
////logrus.Infof("pod %s limit cpu is %s",v.Name,v.Spec.Containers[0].Resources.Limits.Cpu().MilliValue())
|
||||
//rc := v.Spec.Containers[0].Resources.Requests.Cpu().MilliValue()
|
||||
//cpuRequest += rc
|
||||
//rm := v.Spec.Containers[0].Resources.Requests.Memory().Value()
|
||||
//memRequest += rm
|
||||
}
|
||||
var res model.NodePodResource
|
||||
res.CPULimits = cpuLimit
|
||||
@ -423,6 +414,17 @@ func (n *NodeService) CheckNode(nodeUID string) (*model.InstallStatus, *utils.AP
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
//DeleteNodeCondition delete node condition
|
||||
func (n *NodeService) DeleteNodeCondition(nodeUID string, condition client.NodeConditionType) (*client.HostNode, *utils.APIHandleError) {
|
||||
node, err := n.GetNode(nodeUID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node.DeleteCondition(condition)
|
||||
n.nodecluster.UpdateNode(node)
|
||||
return node, nil
|
||||
}
|
||||
|
||||
func dealNext(task *model.ExecedTask, tasks []*model.Task) {
|
||||
for _, v := range tasks {
|
||||
if v.Temp.Depends != nil {
|
||||
|
@ -24,12 +24,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/goodrain/rainbond/cmd/worker/option"
|
||||
"github.com/goodrain/rainbond/db"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
"github.com/goodrain/rainbond/worker/appm/conversion"
|
||||
"github.com/goodrain/rainbond/worker/appm/types/v1"
|
||||
v1 "github.com/goodrain/rainbond/worker/appm/types/v1"
|
||||
"github.com/jinzhu/gorm"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@ -50,6 +52,8 @@ type Storer interface {
|
||||
GetAllAppServices() []*v1.AppService
|
||||
GetAppServiceStatus(serviceID string) string
|
||||
GetAppServicesStatus(serviceIDs []string) map[string]string
|
||||
GetTenantResource(tenantID string) *v1.TenantResource
|
||||
GetTenantRunningApp(tenantID string) []*v1.AppService
|
||||
GetNeedBillingStatus(serviceIDs []string) map[string]string
|
||||
OnDelete(obj interface{})
|
||||
GetPodLister() listcorev1.PodLister
|
||||
@ -684,3 +688,54 @@ func (a *appRuntimeStore) addAbnormalInfo(ai *v1.AbnormalInfo) {
|
||||
func (a *appRuntimeStore) GetPodLister() listcorev1.PodLister {
|
||||
return a.listers.Pod
|
||||
}
|
||||
|
||||
//GetTenantResource get tenant resource
|
||||
func (a *appRuntimeStore) GetTenantResource(tenantID string) *v1.TenantResource {
|
||||
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 {
|
||||
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()
|
||||
}
|
||||
if memorylimit != nil {
|
||||
if ml, ok := memorylimit.AsInt64(); ok {
|
||||
resource.MemoryLimit += ml
|
||||
} else {
|
||||
resource.MemoryLimit += memorylimit.Value()
|
||||
}
|
||||
}
|
||||
if cpurequest != nil {
|
||||
resource.CPURequest += cpurequest.MilliValue()
|
||||
}
|
||||
if memoryrequest != nil {
|
||||
if mr, ok := memoryrequest.AsInt64(); ok {
|
||||
resource.MemoryRequest += mr
|
||||
} else {
|
||||
resource.MemoryRequest += memoryrequest.Value()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return &resource
|
||||
}
|
||||
|
||||
//GetTenantRunningApp get running app by tenant
|
||||
func (a *appRuntimeStore) GetTenantRunningApp(tenantID string) (list []*v1.AppService) {
|
||||
a.appServices.Range(func(k, v interface{}) bool {
|
||||
appService, _ := v.(*v1.AppService)
|
||||
if appService != nil && (appService.TenantID == tenantID || tenantID == corev1.NamespaceAll) && !appService.IsClosed() {
|
||||
list = append(list, appService)
|
||||
}
|
||||
return true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -463,3 +463,12 @@ func (a *AppService) String() string {
|
||||
}(a.services),
|
||||
)
|
||||
}
|
||||
|
||||
//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"`
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package client
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/goodrain/rainbond/worker/appm/types/v1"
|
||||
v1 "github.com/goodrain/rainbond/worker/appm/types/v1"
|
||||
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
|
||||
@ -85,32 +85,6 @@ func (a *AppRuntimeSyncClient) GetStatus(serviceID string) string {
|
||||
return status.Status[serviceID]
|
||||
}
|
||||
|
||||
//GetAllAppDisk get all service disk
|
||||
func (a *AppRuntimeSyncClient) GetAllAppDisk() map[string]float64 {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
status, err := a.AppRuntimeSyncClient.GetAppDisk(ctx, &pb.ServicesRequest{
|
||||
ServiceIds: "",
|
||||
})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return status.Disks
|
||||
}
|
||||
|
||||
//GetAppsDisk get define service disk
|
||||
func (a *AppRuntimeSyncClient) GetAppsDisk(serviceIDs string) map[string]float64 {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
status, err := a.AppRuntimeSyncClient.GetAppDisk(ctx, &pb.ServicesRequest{
|
||||
ServiceIds: serviceIDs,
|
||||
})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return status.Disks
|
||||
}
|
||||
|
||||
//GetStatuss get multiple app status
|
||||
func (a *AppRuntimeSyncClient) GetStatuss(serviceIDs string) map[string]string {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@ -171,3 +145,10 @@ func (a *AppRuntimeSyncClient) GetServiceDeployInfo(serviceID string) (*pb.Deplo
|
||||
func (a *AppRuntimeSyncClient) IsClosedStatus(curStatus string) bool {
|
||||
return curStatus == "" || curStatus == v1.BUILDEFAILURE || curStatus == v1.CLOSED || curStatus == v1.UNDEPLOY || curStatus == v1.BUILDING || curStatus == v1.UNKNOW
|
||||
}
|
||||
|
||||
//GetTenantResource get tenant resource
|
||||
func (a *AppRuntimeSyncClient) GetTenantResource(tenantID string) (*pb.TenantResource, error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
return a.AppRuntimeSyncClient.GetTenantResource(ctx, &pb.TenantRequest{TenantId: tenantID})
|
||||
}
|
||||
|
@ -100,6 +100,45 @@ func (m *ServicesRequest) GetServiceIds() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type TenantRequest struct {
|
||||
TenantId string `protobuf:"bytes,1,opt,name=tenant_id,json=tenantId,proto3" json:"tenant_id,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TenantRequest) Reset() { *m = TenantRequest{} }
|
||||
func (m *TenantRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*TenantRequest) ProtoMessage() {}
|
||||
func (*TenantRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{2}
|
||||
}
|
||||
|
||||
func (m *TenantRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TenantRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TenantRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TenantRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TenantRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TenantRequest.Merge(m, src)
|
||||
}
|
||||
func (m *TenantRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_TenantRequest.Size(m)
|
||||
}
|
||||
func (m *TenantRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TenantRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TenantRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *TenantRequest) GetTenantId() string {
|
||||
if m != nil {
|
||||
return m.TenantId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type StatusMessage struct {
|
||||
Status map[string]string `protobuf:"bytes,1,rep,name=status,proto3" json:"status,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
@ -111,7 +150,7 @@ func (m *StatusMessage) Reset() { *m = StatusMessage{} }
|
||||
func (m *StatusMessage) String() string { return proto.CompactTextString(m) }
|
||||
func (*StatusMessage) ProtoMessage() {}
|
||||
func (*StatusMessage) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{2}
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{3}
|
||||
}
|
||||
|
||||
func (m *StatusMessage) XXX_Unmarshal(b []byte) error {
|
||||
@ -150,7 +189,7 @@ func (m *DiskMessage) Reset() { *m = DiskMessage{} }
|
||||
func (m *DiskMessage) String() string { return proto.CompactTextString(m) }
|
||||
func (*DiskMessage) ProtoMessage() {}
|
||||
func (*DiskMessage) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{3}
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{4}
|
||||
}
|
||||
|
||||
func (m *DiskMessage) XXX_Unmarshal(b []byte) error {
|
||||
@ -189,7 +228,7 @@ func (m *ServiceAppPodList) Reset() { *m = ServiceAppPodList{} }
|
||||
func (m *ServiceAppPodList) String() string { return proto.CompactTextString(m) }
|
||||
func (*ServiceAppPodList) ProtoMessage() {}
|
||||
func (*ServiceAppPodList) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{4}
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{5}
|
||||
}
|
||||
|
||||
func (m *ServiceAppPodList) XXX_Unmarshal(b []byte) error {
|
||||
@ -234,7 +273,7 @@ func (m *ServiceAppPod) Reset() { *m = ServiceAppPod{} }
|
||||
func (m *ServiceAppPod) String() string { return proto.CompactTextString(m) }
|
||||
func (*ServiceAppPod) ProtoMessage() {}
|
||||
func (*ServiceAppPod) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{5}
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{6}
|
||||
}
|
||||
|
||||
func (m *ServiceAppPod) XXX_Unmarshal(b []byte) error {
|
||||
@ -316,7 +355,7 @@ func (m *Container) Reset() { *m = Container{} }
|
||||
func (m *Container) String() string { return proto.CompactTextString(m) }
|
||||
func (*Container) ProtoMessage() {}
|
||||
func (*Container) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{6}
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{7}
|
||||
}
|
||||
|
||||
func (m *Container) XXX_Unmarshal(b []byte) error {
|
||||
@ -370,7 +409,7 @@ func (m *DeployInfo) Reset() { *m = DeployInfo{} }
|
||||
func (m *DeployInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeployInfo) ProtoMessage() {}
|
||||
func (*DeployInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{7}
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{8}
|
||||
}
|
||||
|
||||
func (m *DeployInfo) XXX_Unmarshal(b []byte) error {
|
||||
@ -454,9 +493,81 @@ func (m *DeployInfo) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type TenantResource struct {
|
||||
CpuRequest int64 `protobuf:"varint,1,opt,name=cpu_request,json=cpuRequest,proto3" json:"cpu_request,omitempty"`
|
||||
CpuLimit int64 `protobuf:"varint,2,opt,name=cpu_limit,json=cpuLimit,proto3" json:"cpu_limit,omitempty"`
|
||||
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"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TenantResource) Reset() { *m = TenantResource{} }
|
||||
func (m *TenantResource) String() string { return proto.CompactTextString(m) }
|
||||
func (*TenantResource) ProtoMessage() {}
|
||||
func (*TenantResource) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f94cf1a886c479d6, []int{9}
|
||||
}
|
||||
|
||||
func (m *TenantResource) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TenantResource.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TenantResource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TenantResource.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TenantResource) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TenantResource.Merge(m, src)
|
||||
}
|
||||
func (m *TenantResource) XXX_Size() int {
|
||||
return xxx_messageInfo_TenantResource.Size(m)
|
||||
}
|
||||
func (m *TenantResource) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TenantResource.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TenantResource proto.InternalMessageInfo
|
||||
|
||||
func (m *TenantResource) GetCpuRequest() int64 {
|
||||
if m != nil {
|
||||
return m.CpuRequest
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *TenantResource) GetCpuLimit() int64 {
|
||||
if m != nil {
|
||||
return m.CpuLimit
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *TenantResource) GetMemoryRequest() int64 {
|
||||
if m != nil {
|
||||
return m.MemoryRequest
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *TenantResource) GetMemoryLimit() int64 {
|
||||
if m != nil {
|
||||
return m.MemoryLimit
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *TenantResource) GetRunningAppNum() int64 {
|
||||
if m != nil {
|
||||
return m.RunningAppNum
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*ServiceRequest)(nil), "pb.ServiceRequest")
|
||||
proto.RegisterType((*ServicesRequest)(nil), "pb.ServicesRequest")
|
||||
proto.RegisterType((*TenantRequest)(nil), "pb.TenantRequest")
|
||||
proto.RegisterType((*StatusMessage)(nil), "pb.StatusMessage")
|
||||
proto.RegisterMapType((map[string]string)(nil), "pb.StatusMessage.StatusEntry")
|
||||
proto.RegisterType((*DiskMessage)(nil), "pb.DiskMessage")
|
||||
@ -471,57 +582,65 @@ func init() {
|
||||
proto.RegisterMapType((map[string]string)(nil), "pb.DeployInfo.ReplicatsetEntry")
|
||||
proto.RegisterMapType((map[string]string)(nil), "pb.DeployInfo.SecretsEntry")
|
||||
proto.RegisterMapType((map[string]string)(nil), "pb.DeployInfo.ServicesEntry")
|
||||
proto.RegisterType((*TenantResource)(nil), "pb.TenantResource")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("app_runtime_server.proto", fileDescriptor_f94cf1a886c479d6) }
|
||||
|
||||
var fileDescriptor_f94cf1a886c479d6 = []byte{
|
||||
// 720 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x95, 0x4f, 0x4f, 0xdb, 0x4c,
|
||||
0x10, 0xc6, 0x93, 0x40, 0x42, 0x3c, 0x4e, 0x02, 0xec, 0xfb, 0x52, 0xb9, 0x01, 0x0a, 0xb8, 0x42,
|
||||
0xe2, 0x50, 0xa5, 0x55, 0x5a, 0xd4, 0x00, 0x55, 0xa5, 0xa8, 0x54, 0x28, 0x12, 0xad, 0x90, 0x69,
|
||||
0xcf, 0x91, 0x89, 0x07, 0x64, 0x11, 0xdb, 0x5b, 0xef, 0x06, 0xc9, 0xc7, 0x7e, 0xc1, 0xde, 0xfa,
|
||||
0x45, 0xfa, 0x09, 0xaa, 0xfd, 0xe7, 0x38, 0x09, 0x12, 0x4a, 0x6f, 0xf6, 0x33, 0xf3, 0xdb, 0xf1,
|
||||
0x3e, 0xb3, 0x3b, 0x06, 0xc7, 0xa7, 0x74, 0x98, 0x4e, 0x62, 0x1e, 0x46, 0x38, 0x64, 0x98, 0x3e,
|
||||
0x60, 0xda, 0xa1, 0x69, 0xc2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b, 0x2f, 0x26, 0x79, 0x32, 0xec, 0xfe, 0xaa, 0x40, 0x73, 0x46, 0x7f, 0xa2, 0x3f,
|
||||
0x64, 0x1b, 0xac, 0x00, 0xe9, 0x38, 0xc9, 0x44, 0x54, 0xb9, 0x50, 0x57, 0xc2, 0x20, 0x10, 0x9d,
|
||||
0xd2, 0x41, 0x9e, 0x51, 0x74, 0x56, 0x54, 0xa7, 0x94, 0xf4, 0x2d, 0xa3, 0x48, 0x9e, 0x43, 0x9d,
|
||||
0x26, 0xc1, 0x30, 0xf6, 0x23, 0x74, 0x56, 0x65, 0x74, 0x8d, 0x26, 0xc1, 0x57, 0x3f, 0x42, 0xb2,
|
||||
0x05, 0x35, 0x11, 0x0a, 0xa9, 0x53, 0x55, 0xde, 0xd2, 0x24, 0x18, 0x50, 0xf1, 0x39, 0x42, 0xd6,
|
||||
0xdd, 0xac, 0xa9, 0xcf, 0xa1, 0x49, 0xa0, 0xfa, 0x44, 0xfa, 0x00, 0xa3, 0x24, 0xe6, 0x7e, 0x18,
|
||||
0x63, 0xca, 0x9c, 0x35, 0xb9, 0xd9, 0x83, 0x85, 0xcd, 0x76, 0x3e, 0xe5, 0x39, 0xca, 0xf3, 0x02,
|
||||
0xd4, 0xbe, 0x84, 0xf5, 0xb9, 0xf0, 0x23, 0xee, 0xbf, 0x2c, 0xba, 0x6f, 0x77, 0x9b, 0xa2, 0x44,
|
||||
0x4e, 0x15, 0x9b, 0xf1, 0x1d, 0xac, 0x5c, 0x27, 0x87, 0xd0, 0xca, 0x0b, 0xa9, 0x4d, 0xab, 0x25,
|
||||
0x9b, 0xb9, 0x2a, 0xb7, 0x7e, 0x00, 0x8d, 0x08, 0xa3, 0x24, 0xcd, 0x86, 0xe3, 0x30, 0x0a, 0xb9,
|
||||
0xac, 0x51, 0xf5, 0x6c, 0xa5, 0x5d, 0x0a, 0xc9, 0xfd, 0x5d, 0x05, 0x38, 0x57, 0x36, 0xc7, 0xb7,
|
||||
0x09, 0xd9, 0x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
0xad, 0x3e, 0xa5, 0x9e, 0xfa, 0x7f, 0x5c, 0x67, 0xf1, 0x88, 0xf4, 0xa0, 0x71, 0x81, 0xbc, 0x4f,
|
||||
0xa9, 0xbe, 0xe2, 0xff, 0x15, 0xae, 0xb3, 0xf9, 0x27, 0xb4, 0x37, 0x17, 0x06, 0xba, 0x5b, 0x22,
|
||||
0xef, 0x00, 0x14, 0x29, 0x06, 0xe9, 0xe3, 0xdc, 0xfa, 0xdc, 0x20, 0x76, 0x4b, 0xe4, 0xc4, 0x50,
|
||||
0xa2, 0x71, 0x84, 0x14, 0x28, 0x03, 0x6d, 0x2d, 0x0c, 0x14, 0x31, 0x62, 0xdd, 0x12, 0x39, 0x86,
|
||||
0xe6, 0x05, 0xf2, 0xc2, 0xbd, 0x7c, 0x8c, 0x6e, 0xcd, 0x1e, 0x2c, 0xb7, 0x74, 0x53, 0x93, 0xff,
|
||||
0xc7, 0xb7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x1e, 0xbb, 0x9c, 0x3b, 0x07, 0x00, 0x00,
|
||||
// 831 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5d, 0x6b, 0xe3, 0x46,
|
||||
0x14, 0xb5, 0xfc, 0x15, 0xeb, 0xda, 0x72, 0xd6, 0xd3, 0x6e, 0x51, 0xbd, 0x9b, 0xee, 0xae, 0xca,
|
||||
0x96, 0x7d, 0x58, 0xdc, 0xe2, 0x12, 0xea, 0xcd, 0x86, 0x82, 0x69, 0x4a, 0x30, 0xa4, 0x21, 0x28,
|
||||
0xe9, 0xb3, 0x51, 0xa4, 0x9b, 0x20, 0x62, 0x49, 0x53, 0xcd, 0x28, 0xa0, 0xc7, 0xfe, 0xb3, 0xfe,
|
||||
0x82, 0xbe, 0xf5, 0xcf, 0xf4, 0xa9, 0xcc, 0x97, 0x2c, 0xdb, 0x81, 0x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15, 0xab, 0xde, 0x8c, 0xdf, 0xc1, 0xae, 0x70, 0xf2, 0x1e,
|
||||
0x86, 0x55, 0x21, 0x75, 0x68, 0xb5, 0xa4, 0x53, 0xa1, 0xf2, 0xe8, 0xef, 0x60, 0x90, 0x60, 0x92,
|
||||
0xe5, 0xe5, 0x72, 0x15, 0x27, 0x31, 0x97, 0x35, 0x5a, 0x7e, 0x5f, 0x61, 0x17, 0x02, 0xf2, 0xfe,
|
||||
0xe9, 0x00, 0x9c, 0x29, 0x99, 0xd3, 0xbb, 0x8c, 0xbc, 0x06, 0x5b, 0x2c, 0xc7, 0x68, 0x10, 0x9a,
|
||||
0x35, 0xd7, 0x00, 0xf1, 0x60, 0x20, 0xf4, 0xc2, 0xbb, 0x62, 0x85, 0x0c, 0xb9, 0x6e, 0xd3, 0x06,
|
||||
0x46, 0xbe, 0x01, 0xdd, 0x97, 0x04, 0x53, 0xbe, 0xd9, 0x29, 0x81, 0x90, 0x8f, 0xfa, 0xfe, 0xb4,
|
||||
0xa5, 0xa4, 0xae, 0xbc, 0xbf, 0x55, 0xfd, 0xc9, 0x55, 0x16, 0x69, 0x25, 0x65, 0x16, 0x99, 0x41,
|
||||
0x4f, 0x5f, 0x11, 0xe6, 0x76, 0x24, 0xe3, 0xf5, 0x16, 0xc3, 0x58, 0x80, 0x62, 0x55, 0xd9, 0xe4,
|
||||
0x18, 0x0e, 0x18, 0x86, 0x39, 0x72, 0xd1, 0x5c, 0x41, 0x7c, 0xb5, 0x43, 0x94, 0x51, 0xc5, 0x33,
|
||||
0xb9, 0xe4, 0x33, 0xd8, 0x71, 0x7a, 0x9f, 0x23, 0x63, 0x68, 0xda, 0x7e, 0xb4, 0x45, 0x5c, 0x98,
|
||||
0xb8, 0xa2, 0xae, 0xf3, 0xc9, 0x1c, 0xfa, 0x39, 0xd2, 0x55, 0x1c, 0x06, 0x5c, 0xc8, 0xd3, 0x93,
|
||||
0xf4, 0x37, 0x5b, 0x74, 0x7f, 0x9d, 0xa1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37, 0xe1, 0xf7, 0x5e, 0x83, 0x1c, 0x83, 0x73, 0x8e, 0xbc, 0x66,
|
||||
0x12, 0x4f, 0xb1, 0x87, 0x9b, 0xb7, 0xdc, 0x6b, 0x90, 0x53, 0x18, 0x9d, 0x23, 0xdf, 0xea, 0x81,
|
||||
0xdc, 0xdb, 0xc6, 0x0b, 0x3c, 0x26, 0x75, 0x48, 0xa5, 0x79, 0x8d, 0xdb, 0xae, 0xfc, 0x63, 0xf0,
|
||||
0xe3, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x83, 0x52, 0xd3, 0x34, 0x08, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -537,9 +656,9 @@ const _ = grpc.SupportPackageIsVersion4
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type AppRuntimeSyncClient interface {
|
||||
GetAppStatus(ctx context.Context, in *ServicesRequest, opts ...grpc.CallOption) (*StatusMessage, error)
|
||||
GetAppDisk(ctx context.Context, in *ServicesRequest, opts ...grpc.CallOption) (*DiskMessage, error)
|
||||
GetAppPods(ctx context.Context, in *ServiceRequest, opts ...grpc.CallOption) (*ServiceAppPodList, error)
|
||||
GetDeployInfo(ctx context.Context, in *ServiceRequest, opts ...grpc.CallOption) (*DeployInfo, error)
|
||||
GetTenantResource(ctx context.Context, in *TenantRequest, opts ...grpc.CallOption) (*TenantResource, error)
|
||||
}
|
||||
|
||||
type appRuntimeSyncClient struct {
|
||||
@ -559,15 +678,6 @@ func (c *appRuntimeSyncClient) GetAppStatus(ctx context.Context, in *ServicesReq
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appRuntimeSyncClient) GetAppDisk(ctx context.Context, in *ServicesRequest, opts ...grpc.CallOption) (*DiskMessage, error) {
|
||||
out := new(DiskMessage)
|
||||
err := c.cc.Invoke(ctx, "/pb.AppRuntimeSync/GetAppDisk", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appRuntimeSyncClient) GetAppPods(ctx context.Context, in *ServiceRequest, opts ...grpc.CallOption) (*ServiceAppPodList, error) {
|
||||
out := new(ServiceAppPodList)
|
||||
err := c.cc.Invoke(ctx, "/pb.AppRuntimeSync/GetAppPods", in, out, opts...)
|
||||
@ -586,12 +696,21 @@ func (c *appRuntimeSyncClient) GetDeployInfo(ctx context.Context, in *ServiceReq
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *appRuntimeSyncClient) GetTenantResource(ctx context.Context, in *TenantRequest, opts ...grpc.CallOption) (*TenantResource, error) {
|
||||
out := new(TenantResource)
|
||||
err := c.cc.Invoke(ctx, "/pb.AppRuntimeSync/GetTenantResource", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AppRuntimeSyncServer is the server API for AppRuntimeSync service.
|
||||
type AppRuntimeSyncServer interface {
|
||||
GetAppStatus(context.Context, *ServicesRequest) (*StatusMessage, error)
|
||||
GetAppDisk(context.Context, *ServicesRequest) (*DiskMessage, error)
|
||||
GetAppPods(context.Context, *ServiceRequest) (*ServiceAppPodList, error)
|
||||
GetDeployInfo(context.Context, *ServiceRequest) (*DeployInfo, error)
|
||||
GetTenantResource(context.Context, *TenantRequest) (*TenantResource, error)
|
||||
}
|
||||
|
||||
func RegisterAppRuntimeSyncServer(s *grpc.Server, srv AppRuntimeSyncServer) {
|
||||
@ -616,24 +735,6 @@ func _AppRuntimeSync_GetAppStatus_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AppRuntimeSync_GetAppDisk_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ServicesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AppRuntimeSyncServer).GetAppDisk(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pb.AppRuntimeSync/GetAppDisk",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AppRuntimeSyncServer).GetAppDisk(ctx, req.(*ServicesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AppRuntimeSync_GetAppPods_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ServiceRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -670,6 +771,24 @@ func _AppRuntimeSync_GetDeployInfo_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AppRuntimeSync_GetTenantResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(TenantRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AppRuntimeSyncServer).GetTenantResource(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pb.AppRuntimeSync/GetTenantResource",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AppRuntimeSyncServer).GetTenantResource(ctx, req.(*TenantRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _AppRuntimeSync_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pb.AppRuntimeSync",
|
||||
HandlerType: (*AppRuntimeSyncServer)(nil),
|
||||
@ -678,10 +797,6 @@ var _AppRuntimeSync_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetAppStatus",
|
||||
Handler: _AppRuntimeSync_GetAppStatus_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAppDisk",
|
||||
Handler: _AppRuntimeSync_GetAppDisk_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAppPods",
|
||||
Handler: _AppRuntimeSync_GetAppPods_Handler,
|
||||
@ -690,6 +805,10 @@ var _AppRuntimeSync_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetDeployInfo",
|
||||
Handler: _AppRuntimeSync_GetDeployInfo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetTenantResource",
|
||||
Handler: _AppRuntimeSync_GetTenantResource_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "app_runtime_server.proto",
|
||||
|
@ -3,9 +3,9 @@ package pb;
|
||||
|
||||
service AppRuntimeSync {
|
||||
rpc GetAppStatus (ServicesRequest) returns (StatusMessage) {}
|
||||
rpc GetAppDisk (ServicesRequest) returns (DiskMessage) {}
|
||||
rpc GetAppPods (ServiceRequest) returns (ServiceAppPodList) {}
|
||||
rpc GetDeployInfo (ServiceRequest) returns (DeployInfo) {}
|
||||
rpc GetTenantResource (TenantRequest) returns (TenantResource) {}
|
||||
}
|
||||
|
||||
message ServiceRequest {
|
||||
@ -14,6 +14,9 @@ message ServiceRequest {
|
||||
message ServicesRequest {
|
||||
string service_ids = 1;
|
||||
}
|
||||
message TenantRequest {
|
||||
string tenant_id = 1;
|
||||
}
|
||||
|
||||
message StatusMessage {
|
||||
map<string, string> status = 1;
|
||||
@ -38,7 +41,7 @@ message ServiceAppPod {
|
||||
|
||||
message Container {
|
||||
string container_name = 1;
|
||||
int32 memory_limit = 2;
|
||||
int64 memory_limit = 2;
|
||||
}
|
||||
|
||||
message DeployInfo {
|
||||
@ -51,4 +54,12 @@ message DeployInfo {
|
||||
map<string, string> ingresses = 7;
|
||||
map<string, string> replicatset = 8;
|
||||
string status = 9;
|
||||
}
|
||||
|
||||
message TenantResource {
|
||||
int64 cpu_request = 1;
|
||||
int64 cpu_limit = 2;
|
||||
int64 memory_request = 3;
|
||||
int64 memory_limit = 4;
|
||||
int64 running_app_num = 5;
|
||||
}
|
@ -92,9 +92,20 @@ func (r *RuntimeServer) GetAppStatus(ctx context.Context, re *pb.ServicesRequest
|
||||
}, nil
|
||||
}
|
||||
|
||||
//GetAppDisk get app service volume disk size
|
||||
func (r *RuntimeServer) GetAppDisk(ctx context.Context, re *pb.ServicesRequest) (*pb.DiskMessage, error) {
|
||||
return nil, nil
|
||||
//GetTenantResource get tenant resource
|
||||
//if TenantId is "" will return the sum of the all tenant
|
||||
func (r *RuntimeServer) GetTenantResource(ctx context.Context, re *pb.TenantRequest) (*pb.TenantResource, error) {
|
||||
var tr pb.TenantResource
|
||||
res := r.store.GetTenantResource(re.TenantId)
|
||||
if res == nil {
|
||||
return &tr, nil
|
||||
}
|
||||
tr.RunningAppNum = int64(len(r.store.GetTenantRunningApp(re.TenantId)))
|
||||
tr.CpuLimit = res.CPULimit
|
||||
tr.CpuRequest = res.CPURequest
|
||||
tr.MemoryLimit = res.MemoryLimit / 1024 / 1024
|
||||
tr.MemoryRequest = res.MemoryRequest / 1024 / 1024
|
||||
return &tr, nil
|
||||
}
|
||||
|
||||
//GetAppPods get app pod list
|
||||
|
Loading…
Reference in New Issue
Block a user