| @@ -147,8 +147,8 @@ public class ExperimentInsController extends BaseController { | |||||
| @GetMapping("/pods/realTimeLog") | @GetMapping("/pods/realTimeLog") | ||||
| @ApiOperation("获取pod实时日志请求") | @ApiOperation("获取pod实时日志请求") | ||||
| public GenericsAjaxResult<String> getRealtimePodLogFromPod(@PathVariable("pod_name") String podName, | public GenericsAjaxResult<String> getRealtimePodLogFromPod(@PathVariable("pod_name") String podName, | ||||
| @PathVariable("namespace") String namespace){ | |||||
| return genericsSuccess(this.experimentInsService.getRealtimePodLogFromPod(podName,namespace)); | |||||
| @PathVariable("namespace") String namespace,@PathVariable("container_name") String containerName){ | |||||
| return genericsSuccess(this.experimentInsService.getRealtimePodLogFromPod(podName,namespace,containerName)); | |||||
| } | } | ||||
| @@ -95,5 +95,5 @@ public interface ExperimentInsService { | |||||
| Map<String, Object> getRealtimePodLog(String podName, String startTime); | Map<String, Object> getRealtimePodLog(String podName, String startTime); | ||||
| String getRealtimePodLogFromPod(String podName, String namespace); | |||||
| String getRealtimePodLogFromPod(String podName, String namespace,String container); | |||||
| } | } | ||||
| @@ -522,8 +522,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String getRealtimePodLogFromPod(String podName, String namespace) { | |||||
| return K8sClientUtil.getPodLogs(podName, namespace, logsLines); | |||||
| public String getRealtimePodLogFromPod(String podName, String namespace,String container) { | |||||
| return K8sClientUtil.getPodLogs(podName, namespace,container, logsLines); | |||||
| } | } | ||||
| private boolean isTerminatedState(ExperimentIns ins) throws IOException { | private boolean isTerminatedState(ExperimentIns ins) throws IOException { | ||||
| @@ -404,10 +404,10 @@ public class K8sClientUtil { | |||||
| return pod.getStatus().getPhase(); | return pod.getStatus().getPhase(); | ||||
| } | } | ||||
| public static String getPodLogs(String podName,String namespace,int line) { | |||||
| public static String getPodLogs(String podName,String namespace,String container,int line) { | |||||
| CoreV1Api api = new CoreV1Api(apiClient); | CoreV1Api api = new CoreV1Api(apiClient); | ||||
| try { | try { | ||||
| String log = api.readNamespacedPodLog(podName, namespace, null, null, null, null, null,null, null, line, null); | |||||
| String log = api.readNamespacedPodLog(podName, namespace, StringUtils.isEmpty(container)?null:container, null, null, null, null,null, null, line, null); | |||||
| return log; | return log; | ||||
| } catch (ApiException e) { | } catch (ApiException e) { | ||||
| throw new RuntimeException("获取Pod日志异常", e); | throw new RuntimeException("获取Pod日志异常", e); | ||||