Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Rainbond
Commits
3f0c51d5
Commit
3f0c51d5
authored
3 years ago
by
ZhangSetSail
Browse files
Options
Download
Email Patches
Plain Diff
feat: add application
parent
08b83a65
zqhtest-containerd
feat-containerd
feat-containerd1
feature-k8s
fixbug-560
v5.8.1-release
v5.8.0-release
v5.7.1-release
v5.7.0-release
No related merge requests found
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
api/handler/tenant.go
+15
-10
api/handler/tenant.go
api/model/tenantResourceModel.go
+1
-0
api/model/tenantResourceModel.go
worker/server/pb/app_runtime_server.pb.go
+328
-317
worker/server/pb/app_runtime_server.pb.go
worker/server/pb/app_runtime_server.proto
+1
-0
worker/server/pb/app_runtime_server.proto
worker/server/server.go
+10
-0
worker/server/server.go
with
355 additions
and
327 deletions
+355
-327
api/handler/tenant.go
+
15
-
10
View file @
3f0c51d5
...
...
@@ -120,6 +120,7 @@ func (t *TenantAction) BindTenantsResource(source []*dbmodel.Tenants) api_model.
item
.
RunningAppNum
=
re
.
RunningAppNum
item
.
RunningAppInternalNum
=
re
.
RunningAppInternalNum
item
.
RunningAppThirdNum
=
re
.
RunningAppThirdNum
item
.
RunningApplications
=
re
.
RunningApplications
}
list
.
Add
(
item
)
}
...
...
@@ -341,12 +342,14 @@ func (t *TenantAction) GetTenantsResources(ctx context.Context, tr *api_model.Te
"service_running_num"
:
0
,
"cpu"
:
0
,
"memory"
:
0
,
"app_running_num"
:
0
,
}
tr
,
_
:=
resources
[
tenantID
]
if
tr
!=
nil
{
result
[
tenantID
][
"service_running_num"
]
=
tr
.
RunningAppNum
result
[
tenantID
][
"cpu"
]
=
tr
.
CpuRequest
result
[
tenantID
][
"memory"
]
=
tr
.
MemoryRequest
result
[
tenantID
][
"app_running_num"
]
=
tr
.
RunningApplications
}
}
//query disk used in prometheus
...
...
@@ -367,16 +370,17 @@ func (t *TenantAction) GetTenantsResources(ctx context.Context, tr *api_model.Te
//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"`
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"`
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"`
RunningApplications
int64
`json:"running_applications"`
}
//GetTenantResource get tenant resource
...
...
@@ -391,6 +395,7 @@ func (t *TenantAction) GetTenantResource(tenantID string) (ts TenantResourceStat
ts
.
MemoryLimit
=
tr
.
MemoryLimit
ts
.
MemoryRequest
=
tr
.
MemoryRequest
ts
.
RunningAppNum
=
tr
.
RunningAppNum
ts
.
RunningApplications
=
tr
.
RunningApplications
return
}
...
...
This diff is collapsed.
Click to expand it.
api/model/tenantResourceModel.go
+
1
-
0
View file @
3f0c51d5
...
...
@@ -77,6 +77,7 @@ type TenantAndResource struct {
RunningAppNum
int64
`json:"running_app_num"`
RunningAppInternalNum
int64
`json:"running_app_internal_num"`
RunningAppThirdNum
int64
`json:"running_app_third_num"`
RunningApplications
int64
`json:"running_applications"`
}
//TenantList Tenant list struct
...
...
This diff is collapsed.
Click to expand it.
worker/server/pb/app_runtime_server.pb.go
+
328
-
317
View file @
3f0c51d5
This diff is collapsed.
Click to expand it.
worker/server/pb/app_runtime_server.proto
+
1
-
0
View file @
3f0c51d5
...
...
@@ -104,6 +104,7 @@ message TenantResource {
int64
running_app_num
=
5
;
int64
running_app_third_num
=
10
;
int64
running_app_internal_num
=
11
;
int64
running_applications
=
12
;
}
message
TenantResourceList
{
...
...
This diff is collapsed.
Click to expand it.
worker/server/server.go
+
10
-
0
View file @
3f0c51d5
...
...
@@ -227,18 +227,23 @@ func (r *RuntimeServer) GetTenantResource(ctx context.Context, re *pb.TenantRequ
}
res
:=
r
.
store
.
GetTenantResource
(
tenant
.
Namespace
)
runningApps
:=
r
.
store
.
GetTenantRunningApp
(
re
.
TenantId
)
runningApplications
:=
make
(
map
[
string
]
struct
{})
for
_
,
app
:=
range
runningApps
{
if
app
.
ServiceKind
==
model
.
ServiceKindThirdParty
{
tr
.
RunningAppThirdNum
++
}
else
if
app
.
ServiceKind
==
model
.
ServiceKindInternal
{
tr
.
RunningAppInternalNum
++
}
if
_
,
ok
:=
runningApplications
[
app
.
AppID
];
!
ok
{
runningApplications
[
app
.
AppID
]
=
struct
{}{}
}
}
tr
.
RunningAppNum
=
int64
(
len
(
runningApps
))
tr
.
CpuLimit
=
res
.
CPULimit
tr
.
CpuRequest
=
res
.
CPURequest
tr
.
MemoryLimit
=
res
.
MemoryLimit
/
1024
/
1024
tr
.
MemoryRequest
=
res
.
MemoryRequest
/
1024
/
1024
tr
.
RunningApplications
=
int64
(
len
(
runningApplications
))
return
&
tr
,
nil
}
...
...
@@ -249,13 +254,18 @@ func (r *RuntimeServer) GetTenantResources(context.Context, *pb.Empty) (*pb.Tena
for
_
,
re
:=
range
res
{
var
tr
pb
.
TenantResource
runningApps
:=
r
.
store
.
GetTenantRunningApp
(
re
.
Namespace
)
runningApplications
:=
make
(
map
[
string
]
struct
{})
for
_
,
app
:=
range
runningApps
{
if
app
.
ServiceKind
==
model
.
ServiceKindThirdParty
{
tr
.
RunningAppThirdNum
++
}
else
if
app
.
ServiceKind
==
model
.
ServiceKindInternal
{
tr
.
RunningAppInternalNum
++
}
if
_
,
ok
:=
runningApplications
[
app
.
AppID
];
!
ok
{
runningApplications
[
app
.
AppID
]
=
struct
{}{}
}
}
tr
.
RunningApplications
=
int64
(
len
(
runningApplications
))
tr
.
RunningAppNum
=
int64
(
len
(
runningApps
))
tr
.
CpuLimit
=
re
.
CPULimit
tr
.
CpuRequest
=
re
.
CPURequest
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help