Fixing history, remove, and logs views
This commit is contained in:
1 parent
6785a45415
commit
ee91e02cec
9 files changed
+96
-48
No files matched your search
@@ -2,9 +2,9 @@ import logger from '../config/logger'
|
||||
import { KubernateError } from '../errors'
|
||||
import { Client, config } from 'kubernetes-client'
|
||||
|
||||
const getClonePodStatus = async (cloneName) => {
|
||||
const getClonePodLogs = async (cloneName) => {
|
||||
try {
|
||||
logger.debug("getClonePodStatus on kubernates started.")
|
||||
logger.debug("getClonePodLogs on kubernates started.")
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
let query = {
|
||||
@@ -12,23 +12,23 @@ const getClonePodStatus = async (cloneName) => {
|
||||
"labelSelector": "job-name="+cloneName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const pod = await client.api.v1.namespaces('default').pods.get(query)
|
||||
|
||||
let queryLogs = {
|
||||
"qs":{
|
||||
"tailLines": "15"
|
||||
"tailLines": "20"
|
||||
}
|
||||
}
|
||||
const logs = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).log.get(queryLogs)
|
||||
let logsArray = logs.body.split('\n')
|
||||
|
||||
logger.debug("getClonePodStatus on kubernates successful.")
|
||||
logger.debug("getClonePodLogs on kubernates successful.")
|
||||
|
||||
return JSON.stringify(logsArray, null, 2)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
export default getClonePodStatus
|
||||
export default getClonePodLogs
|
||||
@@ -1,9 +1,11 @@
|
||||
import logger from '../config/logger'
|
||||
import { KubernateError } from '../errors'
|
||||
import { Client, config } from 'kubernetes-client'
|
||||
import { getJobNameFromClone } from '../config/utils'
|
||||
|
||||
const removeClone = async (cloneName) => {
|
||||
const removeClone = async (clone, teamSlug, botSlug) => {
|
||||
try {
|
||||
let cloneName = getJobNameFromClone(teamSlug, botSlug, clone.mode)
|
||||
logger.info("removeClone %s", cloneName)
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
@@ -15,7 +17,7 @@ const removeClone = async (cloneName) => {
|
||||
|
||||
const removed = await client.apis.batch.v1.namespaces('default').jobs(
|
||||
cloneName).delete()
|
||||
|
||||
|
||||
const pod = await client.api.v1.namespaces('default').pods.get(query)
|
||||
const podRemoved = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).delete()
|
||||
|
||||
Reference in new issue
Block a user