Commit 6396dfc1 authored by 智勇's avatar 智勇

统计dev ns

parent d202b0b5
/* eslint-disable guard-for-in */
const schedule = require('node-schedule')
const logger = require('koa-log4').getLogger('deleteTestSvc')
const {
......@@ -14,33 +15,38 @@ const deploy = async (cluster) => {
const summary = {}
for (const namespace of ns.namespaces) {
if (namespace.description === 'test') {
if (namespace.description) {
logger.info('开始检查ns:', namespace.name)
summary[namespace.name] = []
if (!summary[namespace.description]) {
summary[namespace.description] = {}
}
summary[namespace.description][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])
summary[namespace.description][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`
const title = '早。以下测试分支已经一个月没有更新啦,请确认该服务是否还在使用,如无回复将会被删除\n\n'
for (const type in summary) {
let text = ''
for (const i in summary[type]) {
if (summary[type][i].length) {
text = `${text}${i} : \n\n${summary[type][i].join('\n\n')}\n\n`
}
}
if (text) text = title + text
dingTalk('daily 闲置服务检查', text, APP_CONFIG.deleteTestSvcRobot[type])
}
dingTalk('daily 闲置服务检查', text, APP_CONFIG.deleteTestSvcRobot)
logger.info('deleteTestSvc job end')
}
module.exports = () => {
// schedule.scheduleJob('*/2 * * * *', async () => {
// schedule.scheduleJob('*/1 * * * *', async () => {
schedule.scheduleJob('59 9 * * 1-5', async () => {
try {
await deploy('qa')
......
......@@ -15,5 +15,9 @@ 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',
deleteTestSvcRobot: {
test: 'https://oapi.dingtalk.com/robot/send?access_token=e6982a86338979a03d6a1e105469e3010ab1c0b18d80a49a84705c767dbf0e3c',
dev: 'https://oapi.dingtalk.com/robot/send?access_token=08e45c0e77fdb3c18d47559729afe3fc6de624324ced77ebf3f4d0aa1a008de2',
},
}
......@@ -9,7 +9,7 @@ module.exports = async (title, text, url) => {
text,
},
}
if (url) {
if (url && text) {
await awaitRequest({
url,
method: 'POST',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment