You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2026/08/24 06:13:20 UTC

(streampark) branch dev updated: [Console] Fix four DTO/entity defects that break Spark and Flink SQL app management (#4497)

This is an automated email from the ASF dual-hosted git repository.

wolfboys pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new 9f7fe967b [Console] Fix four DTO/entity defects that break Spark and Flink SQL app management (#4497)
9f7fe967b is described below

commit 9f7fe967b80dce793f9a4d0757d22bf96c400f5b
Author: 88fantasy <88...@gmail.com>
AuthorDate: Mon Aug 24 14:13:14 2026 +0800

    [Console] Fix four DTO/entity defects that break Spark and Flink SQL app management (#4497)
    
    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.
---
 .../apache/streampark/console/core/entity/SparkApplication.java  | 4 ++--
 .../java/org/apache/streampark/console/core/entity/SparkEnv.java | 9 +++++----
 .../apache/streampark/console/core/enums/SparkAppStateEnum.java  | 3 +++
 .../console/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 2f59d1cd1..171927938 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 dff43e0e8..c153f245a 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 9e9847670..93bb89846 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 ce5839097..de60c0203 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;