diff --git a/server/src/application/pod.controller.ts b/server/src/application/pod.controller.ts index 9c45cfb742..a04f0b58e5 100644 --- a/server/src/application/pod.controller.ts +++ b/server/src/application/pod.controller.ts @@ -52,6 +52,13 @@ export class PodController { if (!podName) { return ResponseUtil.error('no podName') } + const podNames: PodNameListDto = + await this.podService.getPodNameListByAppid(appid) + + if (!podNames.podNameList.includes(podName)) { + return ResponseUtil.error('podName not exist') + } + const containerNames: ContainerNameListDto = await this.podService.getContainerNameListByPodName(appid, podName) return ResponseUtil.ok(containerNames) diff --git a/server/src/log/log.controller.ts b/server/src/log/log.controller.ts index 51bb5b1746..ee465c2b22 100644 --- a/server/src/log/log.controller.ts +++ b/server/src/log/log.controller.ts @@ -19,7 +19,7 @@ import { Log } from '@kubernetes/client-node' import { GetApplicationNamespace } from 'src/utils/getter' import { RegionService } from 'src/region/region.service' import { ClusterService } from 'src/region/cluster/cluster.service' -import { Observable, async } from 'rxjs' +import { Observable } from 'rxjs' import { PodService } from 'src/application/pod.service' @ApiBearerAuth('Authorization') @@ -107,10 +107,17 @@ export class LogController { if (!containerName) { containerName = appid } - let podNameList: string[] = undefined - if (podName === 'all') { - podNameList = (await this.podService.getPodNameListByAppid(appid)) - .podNameList + + let podNameList: string[] = ( + await this.podService.getPodNameListByAppid(appid) + ).podNameList + + if (!podNameList.includes(podName) && podName !== 'all') { + return ResponseUtil.error('podName not exist') + } + + if (podName !== 'all') { + podNameList = undefined } const region = await this.regionService.findByAppId(appid)