Browse Source

新增实时查询

pull/9/head
fanshuai 2 years ago
parent
commit
6fba822c18
4 changed files with 7 additions and 7 deletions
  1. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java
  2. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java
  3. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  4. +2
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java

+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java View File

@@ -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));
} }






+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java View File

@@ -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);
} }

+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java View File

@@ -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 {


+ 2
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/K8sClientUtil.java View File

@@ -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);


Loading…
Cancel
Save