Unverified Commit 1cdfd5f9 authored by gaoyan's avatar gaoyan Committed by GitHub

Bug fixs (#2487)

* Optimize the process * fix cluster json bug * fix cluster cancel bug * add check on online * fix offline bug * fix job life bug * limitTheParametersPassedToATask * formate code * formate code * formate code * remove jar config * Optimized the automatic process build format * Added code comparison filter * fix dinky-app env bug * fix dinky-app env bug * formate coed * fix some code * fix k8s client
parent bc09f8fc
...@@ -110,10 +110,8 @@ public class ProcessAspect { ...@@ -110,10 +110,8 @@ public class ProcessAspect {
contextHolder.finishedStep(MDC.get(PROCESS_NAME), step, ProcessStatus.FAILED, e); contextHolder.finishedStep(MDC.get(PROCESS_NAME), step, ProcessStatus.FAILED, e);
throw e; throw e;
} finally { } finally {
// If a parent step exists, it is restored after the execution is complete // restored after the execution is complete
if (parentStep != null) { MDC.put(PROCESS_STEP, parentStep);
MDC.put(PROCESS_STEP, parentStep);
}
} }
return result; return result;
} }
......
...@@ -195,7 +195,7 @@ public class ConsoleContextHolder { ...@@ -195,7 +195,7 @@ public class ConsoleContextHolder {
if (e != null) { if (e != null) {
appendLog(processName, null, LogUtil.getError(e.getCause()), true); appendLog(processName, null, LogUtil.getError(e.getCause()), true);
} }
String filePath = String.format("%s/tmp/log/%s.json", System.getProperty("user.dir"), process.getTitle()); String filePath = String.format("%s/tmp/log/%s.json", System.getProperty("user.dir"), processName);
if (FileUtil.exist(filePath)) { if (FileUtil.exist(filePath)) {
Assert.isTrue(FileUtil.del(filePath)); Assert.isTrue(FileUtil.del(filePath));
} }
......
...@@ -25,11 +25,13 @@ import org.dinky.data.annotations.ProcessId; ...@@ -25,11 +25,13 @@ import org.dinky.data.annotations.ProcessId;
import org.dinky.data.dto.DebugDTO; import org.dinky.data.dto.DebugDTO;
import org.dinky.data.dto.TaskDTO; import org.dinky.data.dto.TaskDTO;
import org.dinky.data.dto.TaskRollbackVersionDTO; import org.dinky.data.dto.TaskRollbackVersionDTO;
import org.dinky.data.dto.TaskSaveDTO;
import org.dinky.data.enums.BusinessType; import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.JobLifeCycle; import org.dinky.data.enums.JobLifeCycle;
import org.dinky.data.enums.ProcessType; import org.dinky.data.enums.ProcessType;
import org.dinky.data.enums.Status; import org.dinky.data.enums.Status;
import org.dinky.data.exception.NotSupportExplainExcepition; import org.dinky.data.exception.NotSupportExplainExcepition;
import org.dinky.data.exception.SqlExplainExcepition;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
import org.dinky.data.result.ProTableResult; import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
...@@ -134,11 +136,12 @@ public class TaskController { ...@@ -134,11 +136,12 @@ public class TaskController {
Status.EXECUTE_SUCCESS); Status.EXECUTE_SUCCESS);
} }
@GetMapping("/onLineTask") @GetMapping("/changeTaskLife")
@Log(title = "onLineTask", businessType = BusinessType.TRIGGER) @Log(title = "changeTaskLife", businessType = BusinessType.TRIGGER)
@ApiOperation("onLineTask") @ApiOperation("changeTaskLife")
public Result<Boolean> onLineTask(@RequestParam Integer taskId) { public Result<Boolean> changeTaskLife(@RequestParam Integer taskId, @RequestParam Integer lifeCycle)
if (taskService.changeTaskLifeRecyle(taskId, JobLifeCycle.ONLINE)) { throws SqlExplainExcepition {
if (taskService.changeTaskLifeRecyle(taskId, JobLifeCycle.get(lifeCycle))) {
return Result.succeed(Status.PUBLISH_SUCCESS); return Result.succeed(Status.PUBLISH_SUCCESS);
} else { } else {
return Result.failed(Status.PUBLISH_FAILED); return Result.failed(Status.PUBLISH_FAILED);
...@@ -165,11 +168,11 @@ public class TaskController { ...@@ -165,11 +168,11 @@ public class TaskController {
name = "task", name = "task",
value = "Task", value = "Task",
required = true, required = true,
dataType = "Task", dataType = "TaskSaveDTO",
paramType = "body", paramType = "body",
dataTypeClass = Task.class) dataTypeClass = TaskSaveDTO.class)
public Result<Void> saveOrUpdateTask(@RequestBody Task task) { public Result<Void> saveOrUpdateTask(@RequestBody TaskSaveDTO task) {
if (taskService.saveOrUpdateTask(task)) { if (taskService.saveOrUpdateTask(task.toTaskEntity())) {
return Result.succeed(Status.SAVE_SUCCESS); return Result.succeed(Status.SAVE_SUCCESS);
} else { } else {
return Result.failed(Status.SAVE_FAILED); return Result.failed(Status.SAVE_FAILED);
......
...@@ -119,9 +119,6 @@ public class TaskDTO extends AbstractStatementDTO { ...@@ -119,9 +119,6 @@ public class TaskDTO extends AbstractStatementDTO {
notes = "The identifier of the database") notes = "The identifier of the database")
private Integer databaseId; private Integer databaseId;
@ApiModelProperty(value = "JAR ID", dataType = "Integer", example = "4", notes = "The identifier of the JAR")
private Integer jarId;
@ApiModelProperty( @ApiModelProperty(
value = "Alert Group ID", value = "Alert Group ID",
dataType = "Integer", dataType = "Integer",
...@@ -174,9 +171,6 @@ public class TaskDTO extends AbstractStatementDTO { ...@@ -174,9 +171,6 @@ public class TaskDTO extends AbstractStatementDTO {
@ApiModelProperty(value = "Path", dataType = "String", notes = "Path associated with the task") @ApiModelProperty(value = "Path", dataType = "String", notes = "Path associated with the task")
private String path; private String path;
@ApiModelProperty(value = "JAR Name", dataType = "String", notes = "Name of the associated JAR")
private String jarName;
@ApiModelProperty( @ApiModelProperty(
value = "Cluster Configuration Name", value = "Cluster Configuration Name",
dataType = "String", dataType = "String",
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.dto;
import org.dinky.data.model.Task;
import org.dinky.data.model.TaskExtConfig;
import org.dinky.data.typehandler.JSONObjectHandler;
import org.dinky.mybatis.annotation.Save;
import org.apache.ibatis.type.JdbcType;
import javax.validation.constraints.NotNull;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class TaskSaveDTO {
/** 主键ID */
@TableId(value = "id", type = IdType.AUTO)
@ApiModelProperty(value = "ID", required = true, dataType = "Integer", example = "1", notes = "Primary Key")
private Integer id;
@NotNull(
message = "Name cannot be null",
groups = {Save.class})
@ApiModelProperty(value = "Name", required = true, dataType = "String", example = "Name")
private String name;
@NotNull(
message = "Enabled cannot be null",
groups = {Save.class})
@ApiModelProperty(value = "Enabled", required = true, dataType = "Boolean", example = "true")
private Boolean enabled;
@ApiModelProperty(value = "Dialect", dataType = "String", notes = "Dialect for the task")
private String dialect;
@ApiModelProperty(value = "Type", dataType = "String", notes = "Type of the task")
private String type;
@ApiModelProperty(value = "Check Point", dataType = "Integer", example = "1", notes = "Check point for the task")
private Integer checkPoint;
@ApiModelProperty(value = "Save point strategy", dataType = "SavePointStrategy", notes = "Save point strategy")
private Integer savePointStrategy;
@ApiModelProperty(value = "Save Point Path", dataType = "String", notes = "Save point path for the task")
private String savePointPath;
@ApiModelProperty(value = "Parallelism", dataType = "Integer", example = "4", notes = "Parallelism for the task")
private Integer parallelism;
@ApiModelProperty(
value = "Fragment",
dataType = "Boolean",
example = "true",
notes = "Fragment option for the task")
private Boolean fragment;
@ApiModelProperty(
value = "Statement Set",
dataType = "Boolean",
example = "false",
notes = "Statement set option for the task")
private Boolean statementSet;
@ApiModelProperty(
value = "Batch Model",
dataType = "Boolean",
example = "true",
notes = "Batch model option for the task")
private Boolean batchModel;
@ApiModelProperty(
value = "ClusterInstance ID",
dataType = "Integer",
example = "2001",
notes = "ID of the cluster associated with the task")
private Integer clusterId;
@ApiModelProperty(
value = "Cluster Configuration ID",
dataType = "Integer",
example = "3001",
notes = "ID of the cluster configuration associated with the task")
private Integer clusterConfigurationId;
@ApiModelProperty(
value = "Database ID",
dataType = "Integer",
example = "4001",
notes = "ID of the database associated with the task")
private Integer databaseId;
@ApiModelProperty(
value = "Environment ID",
dataType = "Integer",
example = "6001",
notes = "ID of the environment associated with the task")
private Integer envId;
@ApiModelProperty(
value = "Alert Group ID",
dataType = "Integer",
example = "7001",
notes = "ID of the alert group associated with the task")
private Integer alertGroupId;
@ApiModelProperty(
value = "Configuration JSON",
dataType = "TaskExtConfig",
notes = "Extended configuration in JSON format for the task")
@TableField(typeHandler = JSONObjectHandler.class, jdbcType = JdbcType.VARCHAR)
private TaskExtConfig configJson;
@ApiModelProperty(value = "Note", dataType = "String", notes = "Additional notes for the task")
private String note;
@ApiModelProperty(value = "Statement", dataType = "String", notes = "SQL statement for the task")
private String statement;
public Task toTaskEntity() {
Task task = new Task();
BeanUtil.copyProperties(this, task);
return task;
}
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package org.dinky.data.model.mapping; package org.dinky.data.model.mapping;
import org.dinky.data.model.ClusterConfiguration; import org.dinky.data.model.ClusterConfiguration;
import org.dinky.gateway.model.FlinkClusterConfig;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -75,7 +76,7 @@ public class ClusterConfigurationMapping { ...@@ -75,7 +76,7 @@ public class ClusterConfigurationMapping {
dataType = "String", dataType = "String",
example = "test", example = "test",
notes = "cluster config json") notes = "cluster config json")
private String configJson; private FlinkClusterConfig configJson;
@ApiModelProperty( @ApiModelProperty(
value = "isAvailable", value = "isAvailable",
......
...@@ -55,7 +55,6 @@ import org.springframework.stereotype.Component; ...@@ -55,7 +55,6 @@ import org.springframework.stereotype.Component;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -249,8 +248,8 @@ public class JobRefreshHandler { ...@@ -249,8 +248,8 @@ public class JobRefreshHandler {
if (GatewayType.isDeployCluster(clusterType)) { if (GatewayType.isDeployCluster(clusterType)) {
JobConfig jobConfig = new JobConfig(); JobConfig jobConfig = new JobConfig();
String configJson = jobDataDto.getClusterConfiguration().getConfigJson(); FlinkClusterConfig configJson = jobDataDto.getClusterConfiguration().getConfigJson();
jobConfig.buildGatewayConfig(new JSONObject(configJson).toBean(FlinkClusterConfig.class)); jobConfig.buildGatewayConfig(configJson);
jobConfig.getGatewayConfig().setType(GatewayType.get(clusterType)); jobConfig.getGatewayConfig().setType(GatewayType.get(clusterType));
jobConfig.getGatewayConfig().getFlinkConfig().setJobName(jobInstance.getName()); jobConfig.getGatewayConfig().getFlinkConfig().setJobName(jobInstance.getName());
Gateway.build(jobConfig.getGatewayConfig()).onJobFinishCallback(jobInstance.getStatus()); Gateway.build(jobConfig.getGatewayConfig()).onJobFinishCallback(jobInstance.getStatus());
......
...@@ -26,6 +26,7 @@ import org.dinky.data.dto.TaskRollbackVersionDTO; ...@@ -26,6 +26,7 @@ import org.dinky.data.dto.TaskRollbackVersionDTO;
import org.dinky.data.enums.JobLifeCycle; import org.dinky.data.enums.JobLifeCycle;
import org.dinky.data.exception.ExcuteException; import org.dinky.data.exception.ExcuteException;
import org.dinky.data.exception.NotSupportExplainExcepition; import org.dinky.data.exception.NotSupportExplainExcepition;
import org.dinky.data.exception.SqlExplainExcepition;
import org.dinky.data.model.JobModelOverview; import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobTypeOverView; import org.dinky.data.model.JobTypeOverView;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
...@@ -162,7 +163,7 @@ public interface TaskService extends ISuperService<Task> { ...@@ -162,7 +163,7 @@ public interface TaskService extends ISuperService<Task> {
* @param lifeCycle The new life cycle of the task. * @param lifeCycle The new life cycle of the task.
* @return true if the life cycle is successfully changed, false otherwise. * @return true if the life cycle is successfully changed, false otherwise.
*/ */
boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle); boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle) throws SqlExplainExcepition;
/** /**
* Save or update the given task. * Save or update the given task.
......
...@@ -167,7 +167,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -167,7 +167,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
@ProcessStep(type = ProcessStepType.SUBMIT_PRECHECK) @ProcessStep(type = ProcessStepType.SUBMIT_PRECHECK)
public void preCheckTask(TaskDTO task) throws TaskNotDoneException, SqlExplainExcepition { public void preCheckTask(TaskDTO task) throws TaskNotDoneException {
log.info("Start check and config task, task:{}", task.getName()); log.info("Start check and config task, task:{}", task.getName());
Assert.notNull(task, Status.TASK_NOT_EXIST.getMessage()); Assert.notNull(task, Status.TASK_NOT_EXIST.getMessage());
...@@ -180,21 +180,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -180,21 +180,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
throw new BusException(Status.TASK_STATUS_IS_NOT_DONE.getMessage()); throw new BusException(Status.TASK_STATUS_IS_NOT_DONE.getMessage());
} }
} }
log.info("Start explain Sql,task: {},Dialect:{}", task.getName(), task.getDialect());
List<SqlExplainResult> sqlExplainResults = explainTask(task);
for (SqlExplainResult sqlExplainResult : sqlExplainResults) {
if (!sqlExplainResult.isParseTrue() || !sqlExplainResult.isExplainTrue()) {
throw new SqlExplainExcepition(StrFormatter.format(
"task [{}] sql explain failed, sql [{}], error: [{}]",
task.getName(),
sqlExplainResult.getSql(),
sqlExplainResult.getError()));
}
}
log.info("Explain Sql finish");
} }
@ProcessStep(type = ProcessStepType.SUBMIT_EXECUTE) @ProcessStep(type = ProcessStepType.SUBMIT_EXECUTE)
...@@ -221,11 +206,17 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -221,11 +206,17 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
flinkClusterCfg.getAppConfig().setUserJarParas(buildParams(config.getTaskId())); flinkClusterCfg.getAppConfig().setUserJarParas(buildParams(config.getTaskId()));
flinkClusterCfg.getAppConfig().setUserJarMainAppClass(CommonConstant.DINKY_APP_MAIN_CLASS); flinkClusterCfg.getAppConfig().setUserJarMainAppClass(CommonConstant.DINKY_APP_MAIN_CLASS);
config.buildGatewayConfig(flinkClusterCfg); config.buildGatewayConfig(flinkClusterCfg);
Optional.ofNullable(task.getJobInstanceId()).ifPresent(i -> {
JobInstance jobInstance = jobInstanceService.getById(i);
config.setClusterId(jobInstance.getClusterId());
});
} else { } else {
log.info("Init remote cluster"); Optional.ofNullable(task.getClusterId()).ifPresent(config::setClusterId);
String address = clusterInstanceService.buildEnvironmentAddress(config.isUseRemote(), task.getClusterId());
config.setAddress(address);
} }
log.info("Init remote cluster");
Optional.ofNullable(config.getClusterId()).ifPresent(i -> {
config.setAddress(clusterInstanceService.buildEnvironmentAddress(config.isUseRemote(), i));
});
return config; return config;
} }
...@@ -263,6 +254,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -263,6 +254,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
// 注解自调用会失效,这里通过获取对象方法绕过此限制 // 注解自调用会失效,这里通过获取对象方法绕过此限制
TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class); TaskServiceImpl taskServiceBean = applicationContext.getBean(TaskServiceImpl.class);
taskServiceBean.preCheckTask(taskDTO);
// The job instance does not exist by default,
// so that it does not affect other operations, such as checking the jobmanager address
taskDTO.setJobInstanceId(null);
JobResult jobResult = taskServiceBean.executeJob(taskDTO); JobResult jobResult = taskServiceBean.executeJob(taskDTO);
log.info("Job Submit success"); log.info("Job Submit success");
Task task = new Task(id, jobResult.getJobInstanceId()); Task task = new Task(id, jobResult.getJobInstanceId());
...@@ -427,19 +422,29 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -427,19 +422,29 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
@Override @Override
public boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle) { public boolean changeTaskLifeRecyle(Integer taskId, JobLifeCycle lifeCycle) throws SqlExplainExcepition {
TaskDTO taskInfoById = getTaskInfoById(taskId); TaskDTO task = getTaskInfoById(taskId);
taskInfoById.setStep(lifeCycle.getValue()); task.setStep(lifeCycle.getValue());
if (lifeCycle == JobLifeCycle.ONLINE) { if (lifeCycle == JobLifeCycle.PUBLISH) {
taskVersionService.createTaskVersionSnapshot(taskInfoById); // List<SqlExplainResult> sqlExplainResults = explainTask(task);
} // for (SqlExplainResult sqlExplainResult : sqlExplainResults) {
return saveOrUpdate(taskInfoById.buildTask()); // if (!sqlExplainResult.isParseTrue() || !sqlExplainResult.isExplainTrue()) {
// throw new SqlExplainExcepition(StrFormatter.format(
// "task [{}] sql explain failed, sql [{}], error: [{}]",
// task.getName(),
// sqlExplainResult.getSql(),
// sqlExplainResult.getError()));
// }
// }
taskVersionService.createTaskVersionSnapshot(task);
}
return saveOrUpdate(task.buildTask());
} }
@Override @Override
public boolean saveOrUpdateTask(Task task) { public boolean saveOrUpdateTask(Task task) {
if (JobLifeCycle.ONLINE.equalsValue(task.getStep())) { if (JobLifeCycle.PUBLISH.equalsValue(task.getStep())) {
throw new BusException(Status.TASK_IS_ONLINE.getMessage()); throw new BusException(Status.TASK_IS_ONLINE.getMessage());
} }
......
...@@ -103,7 +103,7 @@ public class Submitter { ...@@ -103,7 +103,7 @@ public class Submitter {
public static String buildSql(AppTask appTask) throws SQLException { public static String buildSql(AppTask appTask) throws SQLException {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// build env task // build env task
if (Asserts.isNotNull(appTask.getEnvId())) { if (Asserts.isNotNull(appTask.getEnvId()) && appTask.getEnvId() > 0) {
AppTask envTask = DBUtil.getTask(appTask.getEnvId()); AppTask envTask = DBUtil.getTask(appTask.getEnvId());
if (Asserts.isNotNullString(envTask.getStatement())) { if (Asserts.isNotNullString(envTask.getStatement())) {
log.info("use statement is enable, load env:{}", envTask.getName()); log.info("use statement is enable, load env:{}", envTask.getName());
......
...@@ -27,26 +27,20 @@ import java.util.Arrays; ...@@ -27,26 +27,20 @@ import java.util.Arrays;
* @since 2022/2/1 16:37 * @since 2022/2/1 16:37
*/ */
public enum JobLifeCycle { public enum JobLifeCycle {
UNKNOWN(0, "未知"), UNKNOWN(0),
DEVELOP(1, "开发"), DEVELOP(1),
ONLINE(2, "上线"); PUBLISH(2);
private Integer value; private Integer value;
private String label;
JobLifeCycle(Integer value, String label) { JobLifeCycle(Integer value) {
this.value = value; this.value = value;
this.label = label;
} }
public Integer getValue() { public Integer getValue() {
return value; return value;
} }
public String getLabel() {
return label;
}
public static JobLifeCycle get(Integer value) { public static JobLifeCycle get(Integer value) {
return Arrays.stream(values()) return Arrays.stream(values())
.filter(item -> item.getValue().equals(value)) .filter(item -> item.getValue().equals(value))
......
...@@ -39,8 +39,10 @@ import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions; ...@@ -39,8 +39,10 @@ import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions;
import org.apache.flink.kubernetes.kubeclient.Fabric8FlinkKubeClient; import org.apache.flink.kubernetes.kubeclient.Fabric8FlinkKubeClient;
import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient; import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory; import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory;
import org.apache.http.util.TextUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.Collections; import java.util.Collections;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
...@@ -111,7 +113,13 @@ public abstract class KubernetesGateway extends AbstractGateway { ...@@ -111,7 +113,13 @@ public abstract class KubernetesGateway extends AbstractGateway {
private void initKubeClient() { private void initKubeClient() {
client = FlinkKubeClientFactory.getInstance().fromConfiguration(configuration, "client"); client = FlinkKubeClientFactory.getInstance().fromConfiguration(configuration, "client");
kubernetesClient = new DefaultKubernetesClient(); String kubeFile = configuration.getString(KubernetesConfigOptions.KUBE_CONFIG_FILE);
if (TextUtils.isEmpty(kubeFile)) {
kubernetesClient = new DefaultKubernetesClient();
} else {
String kubeStr = FileUtil.readString(kubeFile, StandardCharsets.UTF_8);
kubernetesClient = DefaultKubernetesClient.fromConfig(kubeStr);
}
} }
public SavePointResult savepointCluster(String savePoint) { public SavePointResult savepointCluster(String savePoint) {
......
...@@ -30,10 +30,10 @@ import { ...@@ -30,10 +30,10 @@ import {
} from '@/pages/DataStudio/HeaderContainer/function'; } from '@/pages/DataStudio/HeaderContainer/function';
import { import {
cancelTask, cancelTask,
changeTaskLife,
debugTask, debugTask,
executeSql, executeSql,
getJobPlan, getJobPlan
onLineTask
} from '@/pages/DataStudio/HeaderContainer/service'; } from '@/pages/DataStudio/HeaderContainer/service';
import { StateType, TabsPageSubType, TabsPageType, VIEW } from '@/pages/DataStudio/model'; import { StateType, TabsPageSubType, TabsPageType, VIEW } from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
...@@ -182,12 +182,20 @@ const HeaderContainer = (props: any) => { ...@@ -182,12 +182,20 @@ const HeaderContainer = (props: any) => {
const handleChangeJobLife = async () => { const handleChangeJobLife = async () => {
if (!currentData) return; if (!currentData) return;
if (isOnline(currentData)) { if (isOnline(currentData)) {
await cancelTask(l('global.table.lifecycle.offline'), currentData.id); await changeTaskLife(
l('global.table.lifecycle.offline'),
currentData.id,
JOB_LIFE_CYCLE.DEVELOP
);
currentData.step = JOB_LIFE_CYCLE.DEVELOP; currentData.step = JOB_LIFE_CYCLE.DEVELOP;
} else { } else {
const saved = await handleSave(); const saved = await handleSave();
if (saved) { if (saved) {
await onLineTask(l('global.table.lifecycle.publishing'), currentData.id); await changeTaskLife(
l('global.table.lifecycle.publishing'),
currentData.id,
JOB_LIFE_CYCLE.PUBLISH
);
currentData.step = JOB_LIFE_CYCLE.PUBLISH; currentData.step = JOB_LIFE_CYCLE.PUBLISH;
} }
} }
......
...@@ -41,12 +41,8 @@ export function cancelTask(title: string, id: number) { ...@@ -41,12 +41,8 @@ export function cancelTask(title: string, id: number) {
return handleGetOption('api/task/cancel', title, { id }); return handleGetOption('api/task/cancel', title, { id });
} }
export function onLineTask(title = '', id: number) { export function changeTaskLife(title = '', id: number, life: number) {
return handleGetOption('api/task/onLineTask', title, { taskId: id }); return handleGetOption('api/task/changeTaskLife', title, { taskId: id, lifeCycle: life });
}
export function offLinelTask(id: number) {
return handleGetOption('api/task/cancel', '', { taskId: id });
} }
export const isSql = (dialect: string) => { export const isSql = (dialect: string) => {
......
/* /*
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0 * The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at * the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
...@@ -49,5 +49,13 @@ export const TASK_VAR_FILTER = [ ...@@ -49,5 +49,13 @@ export const TASK_VAR_FILTER = [
'useAutoCancel', 'useAutoCancel',
'status', 'status',
'step', 'step',
'jobConfig' 'jobConfig',
'note',
'step',
'versionId',
'clusterName',
'clusterConfigurationName',
'databaseName',
'envName',
'alertGroupName',
]; ];
...@@ -90,7 +90,6 @@ export type TaskType = { ...@@ -90,7 +90,6 @@ export type TaskType = {
clusterConfigurationName?: string; clusterConfigurationName?: string;
databaseId?: number; databaseId?: number;
databaseName?: string; databaseName?: string;
jarId?: number;
envId?: number; envId?: number;
jobInstanceId?: number; jobInstanceId?: number;
note?: string; note?: string;
......
...@@ -278,7 +278,8 @@ LEFT JOIN ...@@ -278,7 +278,8 @@ LEFT JOIN
-- 删除dinky_job_history 的 jar_json 字段 -- 删除dinky_job_history 的 jar_json 字段
alter table dinky_job_history drop column jar_json; alter table dinky_job_history drop column jar_json;
alter table dinky_task drop column jar_id; alter table dinky_task drop column jar_id;
UPDATE dinky_task_version SET task_configure=JSON_REMOVE(task_configure, '$.jarId');
UPDATE dinky_history SET config_json=JSON_REMOVE(config_json, '$.jarId');
insert into `dinky_flink_document` values (218, 'Reference', '建表语句', 'Streaming', 'EXECUTE CDCSOURCE print', 'Whole library synchronization print', 'EXECUTE CDCSOURCE demo_print WITH ( insert into `dinky_flink_document` values (218, 'Reference', '建表语句', 'Streaming', 'EXECUTE CDCSOURCE print', 'Whole library synchronization print', 'EXECUTE CDCSOURCE demo_print WITH (
''connector'' = ''mysql-cdc'', ''connector'' = ''mysql-cdc'',
......
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