gyfora commented on a change in pull request #112:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/112#discussion_r841198754



##########
File path: 
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/validation/DefaultValidator.java
##########
@@ -270,4 +271,37 @@
 
         return Optional.empty();
     }
+
+    // validate session job
+
+    @Override
+    public Optional<String> validate(
+            FlinkSessionJob sessionJob, Optional<FlinkDeployment> session) {
+
+        return firstPresent(
+                validateNotApplicationCluster(session),
+                validateSessionClusterId(sessionJob, session));
+    }
+
+    private Optional<String> validateSessionClusterId(
+            FlinkSessionJob sessionJob, Optional<FlinkDeployment> session) {
+        return session.map(
+                s -> {
+                    if 
(!s.getMetadata().getName().equals(sessionJob.getSpec().getClusterId())) {
+                        return "The session job's cluster id is not match with 
the session cluster";
+                    }
+                    return null;
+                });
+    }
+
+    private Optional<String> 
validateNotApplicationCluster(Optional<FlinkDeployment> session) {
+        return session.map(
+                s -> {
+                    if (s.getSpec().getJob() != null) {
+                        return "Can not submit to application cluster";
+                    } else {
+                        return null;

Review comment:
       Wouldn't this throw a nullpointer exception in the Optional logic?
   I think this should be a `flatMap` and return Optional.of(error) or empty

##########
File path: 
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/validation/FlinkResourceValidator.java
##########
@@ -31,4 +32,13 @@
      * @return Optional error string, should be present iff validation 
resulted in an error
      */
     Optional<String> validate(FlinkDeployment deployment);

Review comment:
       I think this method should be called `validateDeployment`

##########
File path: 
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/validation/FlinkResourceValidator.java
##########
@@ -31,4 +32,13 @@
      * @return Optional error string, should be present iff validation 
resulted in an error
      */
     Optional<String> validate(FlinkDeployment deployment);
+
+    /**
+     * Validate and return optional error.
+     *
+     * @param sessionJob the session job to be validated.
+     * @param session the target session cluster of the session job to be 
validated.
+     * @return Optional error string, should be present iff validation 
resulted in an error
+     */
+    Optional<String> validate(FlinkSessionJob sessionJob, 
Optional<FlinkDeployment> session);

Review comment:
       I think this method should be called validateSessionJob




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to