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
701b6ca3
Commit
701b6ca3
authored
3 years ago
by
yangk
Browse files
Options
Download
Email Patches
Plain Diff
return appstatuses
parent
7221c487
main
Develop-V5.X
V5.3
V5.4
feat-containerd
feat-containerd1
feature-k8s
fixbug-560
master
zqhtest-containerd
v5.8.1-release
v5.8.0-release
v5.7.1-release
v5.7.0-release
v5.6.0-release
v5.5.0-release
v5.5.0-dind
v5.4.1-release
v5.4.0-release
v5.3.3-release
v5.3.2-release
No related merge requests found
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
api/api/api_interface.go
+1
-0
api/api/api_interface.go
api/api_routers/version2/v2Routers.go
+1
-0
api/api_routers/version2/v2Routers.go
api/controller/application.go
+14
-0
api/controller/application.go
api/handler/application_handler.go
+45
-0
api/handler/application_handler.go
api/model/app.go
+3
-0
api/model/app.go
api/model/model.go
+5
-0
api/model/model.go
db/dao/dao.go
+1
-0
db/dao/dao.go
db/mysql/dao/application.go
+9
-0
db/mysql/dao/application.go
with
79 additions
and
0 deletions
+79
-0
api/api/api_interface.go
+
1
-
0
View file @
701b6ca3
...
...
@@ -176,6 +176,7 @@ type ApplicationInterface interface {
ListConfigGroups
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
SyncComponents
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
SyncAppConfigGroups
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
ListAppStatuses
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
}
//Gatewayer gateway api interface
...
...
This diff is collapsed.
Click to expand it.
api/api_routers/version2/v2Routers.go
+
1
-
0
View file @
701b6ca3
...
...
@@ -144,6 +144,7 @@ func (v2 *V2) tenantNameRouter() chi.Router {
r
.
Post
(
"/batch_create_apps"
,
controller
.
GetManager
()
.
BatchCreateApp
)
r
.
Get
(
"/apps"
,
controller
.
GetManager
()
.
ListApps
)
r
.
Post
(
"/checkResourceName"
,
controller
.
GetManager
()
.
CheckResourceName
)
r
.
Get
(
"/appstatuses"
,
controller
.
GetManager
()
.
ListAppStatuses
)
r
.
Mount
(
"/apps/{app_id}"
,
v2
.
applicationRouter
())
//get some service pod info
r
.
Get
(
"/pods"
,
controller
.
Pods
)
...
...
This diff is collapsed.
Click to expand it.
api/controller/application.go
+
14
-
0
View file @
701b6ca3
...
...
@@ -254,3 +254,17 @@ func (a *ApplicationController) ListHelmAppReleases(w http.ResponseWriter, r *ht
httputil
.
ReturnSuccess
(
r
,
w
,
releases
)
}
// ListAppStatuses returns the status of the applications.
func
(
a
*
ApplicationController
)
ListAppStatuses
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
req
model
.
AppStatusesReq
if
!
httputil
.
ValidatorRequestStructAndErrorResponse
(
r
,
w
,
&
req
,
nil
)
{
return
}
res
,
err
:=
handler
.
GetApplicationHandler
()
.
ListAppStatuses
(
r
.
Context
(),
req
.
AppIDs
)
if
err
!=
nil
{
httputil
.
ReturnBcodeError
(
r
,
w
,
err
)
return
}
httputil
.
ReturnSuccess
(
r
,
w
,
res
)
}
This diff is collapsed.
Click to expand it.
api/handler/application_handler.go
+
45
-
0
View file @
701b6ca3
...
...
@@ -60,6 +60,7 @@ type ApplicationHandler interface {
SyncComponents
(
app
*
dbmodel
.
Application
,
components
[]
*
model
.
Component
,
deleteComponentIDs
[]
string
)
error
SyncComponentConfigGroupRels
(
tx
*
gorm
.
DB
,
app
*
dbmodel
.
Application
,
components
[]
*
model
.
Component
)
error
SyncAppConfigGroups
(
app
*
dbmodel
.
Application
,
appConfigGroups
[]
model
.
AppConfigGroup
)
error
ListAppStatuses
(
ctx
context
.
Context
,
appIDs
[]
string
)
([]
*
model
.
AppStatus
,
error
)
}
// NewApplicationHandler creates a new Tenant Application Handler.
...
...
@@ -436,6 +437,8 @@ func (a *ApplicationAction) GetStatus(ctx context.Context, app *dbmodel.Applicat
Overrides
:
status
.
Overrides
,
Version
:
status
.
Version
,
Conditions
:
conditions
,
AppID
:
app
.
AppID
,
AppName
:
app
.
AppName
,
}
return
res
,
nil
}
...
...
@@ -686,3 +689,45 @@ func (a *ApplicationAction) deleteByComponentIDs(tx *gorm.DB, app *dbmodel.Appli
}
return
db
.
GetManager
()
.
TenantServceAutoscalerRuleMetricsDaoTransactions
(
tx
)
.
DeleteByRuleIDs
(
autoScaleRuleIDs
)
}
// ListAppStatuses -
func
(
a
*
ApplicationAction
)
ListAppStatuses
(
ctx
context
.
Context
,
appIDs
[]
string
)
([]
*
model
.
AppStatus
,
error
)
{
var
appstatuses
[]
*
model
.
AppStatus
apps
,
err
:=
db
.
GetManager
()
.
ApplicationDao
()
.
ListByAppIDs
(
appIDs
)
if
err
!=
nil
{
return
nil
,
err
}
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
5
*
time
.
Second
)
defer
cancel
()
for
_
,
app
:=
range
apps
{
status
,
err
:=
a
.
statusCli
.
GetAppStatus
(
ctx
,
&
pb
.
AppStatusReq
{
AppId
:
app
.
AppID
,
})
if
err
!=
nil
{
logrus
.
Errorf
(
"get app status failed %v"
,
err
)
continue
}
diskUsage
:=
a
.
getDiskUsage
(
app
.
AppID
)
var
cpu
*
int64
if
status
.
SetCPU
{
cpu
=
commonutil
.
Int64
(
status
.
Cpu
)
}
var
memory
*
int64
if
status
.
SetMemory
{
memory
=
commonutil
.
Int64
(
status
.
Memory
)
}
appstatuses
=
append
(
appstatuses
,
&
model
.
AppStatus
{
Status
:
status
.
Status
,
CPU
:
cpu
,
Memory
:
memory
,
Disk
:
int64
(
diskUsage
),
Phase
:
status
.
Phase
,
Overrides
:
status
.
Overrides
,
Version
:
status
.
Version
,
AppID
:
app
.
AppID
,
AppName
:
app
.
AppName
,
})
}
return
appstatuses
,
nil
}
This diff is collapsed.
Click to expand it.
api/model/app.go
+
3
-
0
View file @
701b6ca3
...
...
@@ -12,8 +12,11 @@ type AppPort struct {
// AppStatus -
type
AppStatus
struct
{
AppID
string
`json:"app_id"`
AppName
string
`json:"app_name"`
Status
string
`json:"status"`
CPU
*
int64
`json:"cpu"`
GPU
*
int64
`json:"gpu"`
Memory
*
int64
`json:"memory"`
Disk
int64
`json:"disk"`
Phase
string
`json:"phase"`
...
...
This diff is collapsed.
Click to expand it.
api/model/model.go
+
5
-
0
View file @
701b6ca3
...
...
@@ -2003,3 +2003,8 @@ func (a *AppConfigGroupRelations) DbModel(appID, serviceID, serviceAlias string)
type
SyncAppConfigGroup
struct
{
AppConfigGroups
[]
AppConfigGroup
`json:"app_config_groups"`
}
// AppStatusesReq -
type
AppStatusesReq
struct
{
AppIDs
[]
string
`json:"app_ids"`
}
This diff is collapsed.
Click to expand it.
db/dao/dao.go
+
1
-
0
View file @
701b6ca3
...
...
@@ -75,6 +75,7 @@ type ApplicationDao interface {
GetAppByID
(
appID
string
)
(
*
model
.
Application
,
error
)
DeleteApp
(
appID
string
)
error
GetByServiceID
(
sid
string
)
(
*
model
.
Application
,
error
)
ListByAppIDs
(
appIDs
[]
string
)
([]
*
model
.
Application
,
error
)
}
//AppConfigGroupDao Application config group Dao
...
...
This diff is collapsed.
Click to expand it.
db/mysql/dao/application.go
+
9
-
0
View file @
701b6ca3
...
...
@@ -84,3 +84,12 @@ func (a *ApplicationDaoImpl) DeleteApp(appID string) error {
}
return
a
.
DB
.
Delete
(
&
app
)
.
Error
}
// ListByAppIDs -
func
(
a
*
ApplicationDaoImpl
)
ListByAppIDs
(
appIDs
[]
string
)
([]
*
model
.
Application
,
error
)
{
var
datas
[]
*
model
.
Application
if
err
:=
a
.
DB
.
Where
(
"app_id in (?)"
,
appIDs
)
.
Find
(
&
datas
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
return
datas
,
nil
}
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