Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tke-eos
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
tke-eos
Commits
d202b0b5
Commit
d202b0b5
authored
Mar 20, 2020
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
闲置服务检查
parent
c20894cb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
1 deletion
+58
-1
dailySyncDB.js
app/dailySyncDB.js
+1
-1
deleteTestSvc.js
app/deleteTestSvc.js
+51
-0
index.js
app/index.js
+2
-0
service.js
app/service.js
+3
-0
index.js
config/index.js
+1
-0
No files found.
app/dailySyncDB.js
View file @
d202b0b5
...
...
@@ -66,7 +66,7 @@ const syncDB = async (cluster) => {
module
.
exports
=
()
=>
{
// schedule.scheduleJob('*/2 * * * *', async () => {
schedule
.
scheduleJob
(
'
0 23
* * *
'
,
async
()
=>
{
schedule
.
scheduleJob
(
'
50 7
* * *
'
,
async
()
=>
{
try
{
await
syncDB
(
'
qa
'
)
}
catch
(
e
)
{
...
...
app/deleteTestSvc.js
0 → 100644
View file @
d202b0b5
const
schedule
=
require
(
'
node-schedule
'
)
const
logger
=
require
(
'
koa-log4
'
).
getLogger
(
'
deleteTestSvc
'
)
const
{
getServicesFormat
,
getAllNamespace
,
}
=
require
(
'
../kubeService/service
'
)
const
getClient
=
require
(
'
../resource/getClient
'
)
const
dingTalk
=
require
(
'
../utils/dingTalk
'
)
const
APP_CONFIG
=
require
(
'
../config
'
)
const
deploy
=
async
(
cluster
)
=>
{
logger
.
info
(
'
deleteTestSvc job start
'
)
const
client
=
await
getClient
(
cluster
)
const
ns
=
await
getAllNamespace
(
client
.
clientInfo
)
const
summary
=
{}
for
(
const
namespace
of
ns
.
namespaces
)
{
if
(
namespace
.
description
===
'
test
'
)
{
logger
.
info
(
'
开始检查ns:
'
,
namespace
.
name
)
summary
[
namespace
.
name
]
=
[]
const
svcs
=
await
getServicesFormat
(
client
.
clientInfo
,
namespace
.
name
)
for
(
const
svc
of
svcs
)
{
if
(
svc
.
labels
.
type
!==
'
base
'
&&
!~
svc
.
image
.
indexOf
(
'
latest
'
)
&&
!~
svc
.
image
.
search
(
'
:master-
'
)
&&
~
svc
.
createdAt
.
search
(
'
month
'
))
{
summary
[
namespace
.
name
].
push
(
svc
.
image
.
split
(
'
/
'
)[
2
])
}
}
logger
.
info
(
'
ns:
'
,
namespace
.
name
,
'
检查完毕
'
)
}
}
let
text
=
'
早。以下测试分支已经一个月没有更新啦,请确认该服务是否还在使用,如无回复将会被删除
\n\n
'
for
(
const
i
in
summary
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
summary
,
i
))
{
if
(
summary
[
i
].
length
)
{
text
=
`
${
text
}${
i
}
: \n\n
${
summary
[
i
].
join
(
'
\n\n
'
)}
\n\n`
}
}
}
dingTalk
(
'
daily 闲置服务检查
'
,
text
,
APP_CONFIG
.
deleteTestSvcRobot
)
logger
.
info
(
'
deleteTestSvc job end
'
)
}
module
.
exports
=
()
=>
{
// schedule.scheduleJob('*/2 * * * *', async () => {
schedule
.
scheduleJob
(
'
59 9 * * 1-5
'
,
async
()
=>
{
try
{
await
deploy
(
'
qa
'
)
}
catch
(
e
)
{
logger
.
info
(
'
deleteTestSvc
'
,
e
)
}
});
}
app/index.js
View file @
d202b0b5
...
...
@@ -15,6 +15,7 @@ const tag = require('./tag')
const
cluster
=
require
(
'
./cluster
'
)
const
ingressRoute
=
require
(
'
./ingress
'
)
const
deploy
=
require
(
'
./restartLatest
'
)
const
deleteTestSvc
=
require
(
'
./deleteTestSvc
'
)
const
dailySyncDB
=
require
(
'
./dailySyncDB
'
)
const
client
=
require
(
'
../middleware/client
'
)
...
...
@@ -59,6 +60,7 @@ exports.start = function (port) {
// 加载所有路由
loadRoutes
(
router
)
deploy
()
deleteTestSvc
()
dailySyncDB
()
app
.
use
(
log4js
.
koaLogger
(
log4js
.
getLogger
(
'
http
'
),
{
level
:
'
auto
'
,
format
:
logFormat
}))
app
.
use
(
router
.
routes
())
...
...
app/service.js
View file @
d202b0b5
...
...
@@ -147,6 +147,9 @@ router.post('/modifyDeploy', async (ctx) => {
if
(
!
data
.
label
)
{
data
.
label
=
data
.
type
}
if
(
data
.
type
===
'
base
'
)
{
data
.
type
=
data
.
serviceName
}
const
resources
=
await
makeResouce
(
data
.
serviceName
,
data
.
label
)
data
.
resources
=
resources
await
deployUpdate
(
ctx
.
cluterParams
,
ctx
.
client
,
data
)
...
...
config/index.js
View file @
d202b0b5
...
...
@@ -15,4 +15,5 @@ module.exports = {
],
qaapiHost
:
'
http://qaapi.liangkebang.com
'
,
latestDingRobot
:
'
https://oapi.dingtalk.com/robot/send?access_token=99e801a2cf26680e6ce09cb12f830c21a03ae3df07d18f6a38e1db54c0e95f2c
'
,
deleteTestSvcRobot
:
'
https://oapi.dingtalk.com/robot/send?access_token=e6982a86338979a03d6a1e105469e3010ab1c0b18d80a49a84705c767dbf0e3c
'
,
}
Write
Preview
Markdown
is supported
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