From add10644b73b96c29781b80245c1e83a999fff5f Mon Sep 17 00:00:00 2001 From: 88fantasy <88fantasy@gmail.com> Date: Fri, 14 Aug 2026 10:20:42 +0800 Subject: [PATCH] [Console] Fix four DTO/entity defects that break Spark and Flink SQL app management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each of these makes a normal UI operation fail outright; all four are reproducible on a clean install. 1. FlinkAppCreateRequest carries no sqlId, though the frontend sends one and FlinkApplicationManageServiceImpl.updateFlinkSqlJob() requires it for an application that has already been started. BeanUtils.copyProperties silently skips the absent field, the entity's sqlId stays null, and the save fails with "Flink sql is null, update flink sql job failed." Only never-started applications were unaffected, since those take the candidate branch. SparkAppCreateRequest and FlinkAppResponse both already declare sqlId — this was a one-sided omission on the Flink request DTOs. 2. SparkAppStateEnum.of(Integer) compares appState.value == state, which unboxes. SparkAppListQueryRequest has a scalar state field that is null whenever the list is not filtered by status, so the copy to SparkApplication leaves state null and shouldTracking() -> getStateEnum() -> of(null) throws NPE: /spark/app/list returns 500 for everyone. Now returns OTHER for null. FlinkAppStateEnum.getState(Integer) has the same unboxing shape but no scalar state field reaching it today, so it is left alone here. 3. SparkEnv.doSetSparkConf() only assigned sparkConf when conf/spark-defaults.conf existed. A stock Spark distribution ships only spark-defaults.conf.template, so for an unmodified Spark home the field stays null and the insert fails on t_spark_env.spark_conf, which is NOT NULL with no default — no Spark home could be registered at all. An absent file is now stored as an empty conf. 4. SparkApplication.k8sImagePullPolicy was a primitive int while SparkAppCreateRequest declares Integer and the Spark frontend never sends the field, so BeanUtils.copyProperties unboxed null and /spark/app/create returned 500 for every UI-created Spark application. The entity field now matches its nullable column. --- .../streampark/console/core/entity/SparkApplication.java | 4 ++-- .../apache/streampark/console/core/entity/SparkEnv.java | 9 +++++---- .../streampark/console/core/enums/SparkAppStateEnum.java | 3 +++ .../core/request/flink/FlinkAppCreateRequest.java | 2 ++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java index 2f59d1cd17..1719279386 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java @@ -127,8 +127,8 @@ public class SparkApplication extends BaseEntity implements ApplicationEntitySup /** spark docker base image */ private String k8sContainerImage; - /** k8s image pull policy */ - private int k8sImagePullPolicy; + /** k8s image pull policy — nullable, matching t_spark_app.k8s_image_pull_policy */ + private Integer k8sImagePullPolicy; /** k8s spark service account */ private String k8sServiceAccount; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java index dff43e0e80..c153f245a1 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkEnv.java @@ -73,10 +73,11 @@ public class SparkEnv implements Serializable { public void doSetSparkConf() throws ApiDetailException { try { File yaml = new File(this.sparkHome.concat("/conf/spark-defaults.conf")); - if (yaml.exists()) { - String sparkConf = FileUtils.readFileToString(yaml, StandardCharsets.UTF_8); - this.sparkConf = DeflaterUtils.zipString(sparkConf); - } + // A stock Spark distribution ships only spark-defaults.conf.template, so an absent file + // is the normal case, not an error — but t_spark_env.spark_conf is NOT NULL, so it still + // has to be written as an empty conf rather than left null. + String sparkConf = yaml.exists() ? FileUtils.readFileToString(yaml, StandardCharsets.UTF_8) : ""; + this.sparkConf = DeflaterUtils.zipString(sparkConf); } catch (Exception e) { throw new ApiDetailException(e); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/SparkAppStateEnum.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/SparkAppStateEnum.java index 9e98476701..93bb89846f 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/SparkAppStateEnum.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/SparkAppStateEnum.java @@ -78,6 +78,9 @@ public enum SparkAppStateEnum { } public static SparkAppStateEnum of(Integer state) { + if (state == null) { + return SparkAppStateEnum.OTHER; + } for (SparkAppStateEnum appState : values()) { if (appState.value == state) { return appState; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/flink/FlinkAppCreateRequest.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/flink/FlinkAppCreateRequest.java index ce5839097a..de60c0203b 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/flink/FlinkAppCreateRequest.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/request/flink/FlinkAppCreateRequest.java @@ -54,6 +54,8 @@ public class FlinkAppCreateRequest implements Serializable { private String flinkSql; + private Long sqlId; + @NotNull @ApiParam(description = "Application type", required = true) private Integer appType;