You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/08 20:12:48 UTC

[GitHub] [flink-kubernetes-operator] gyfora opened a new pull request, #342: [FLINK-28846] Trigger event on validation error

gyfora opened a new pull request, #342:
URL: https://github.com/apache/flink-kubernetes-operator/pull/342

   ## What is the purpose of the change
   
   Trigger Warning event on validation error. This is very useful in cases where the webhook is not enabled.
   
   ![image](https://user-images.githubusercontent.com/5880972/183505832-dd919d0d-05a5-4a00-aaf1-39791f0ba535.png)
   
   ## Brief change log
   
    - Add event triggering to validation logic
    - Improve ResourceLifecycleState in case of failed initial valiadation: `CREATED` -> `FAILED`
   
   ## Verifying this change
   
   Extended `FlinkDeploymentControllerTest` to cover the new event triggering.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changes to the `CustomResourceDescriptors`: no
     - Core observer or reconciler logic that is regularly executed: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #342: [FLINK-28846] Trigger event on validation error

Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #342:
URL: https://github.com/apache/flink-kubernetes-operator/pull/342#discussion_r940967644


##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentControllerTest.java:
##########
@@ -864,6 +872,23 @@ public void testSuccessfulObservationShouldClearErrors() throws Exception {
                 appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
     }
 
+    @Test
+    public void testValidationError() throws Exception {
+        assertTrue(testController.events().isEmpty());
+        var flinkDeployment = TestUtils.buildApplicationCluster();
+        flinkDeployment.getSpec().getJob().setParallelism(-1);
+        testController.reconcile(flinkDeployment, context);
+
+        assertEquals(1, testController.events().size());
+        assertEquals(
+                ResourceLifecycleState.FAILED, flinkDeployment.getStatus().getLifecycleState());
+
+        var event = testController.events().remove();
+        assertEquals("Warning", event.getType());

Review Comment:
   nit: You can consider using Enum.valueOf() here



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-kubernetes-operator] gyfora commented on a diff in pull request #342: [FLINK-28846] Trigger event on validation error

Posted by GitBox <gi...@apache.org>.
gyfora commented on code in PR #342:
URL: https://github.com/apache/flink-kubernetes-operator/pull/342#discussion_r940969053


##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentControllerTest.java:
##########
@@ -864,6 +872,23 @@ public void testSuccessfulObservationShouldClearErrors() throws Exception {
                 appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
     }
 
+    @Test
+    public void testValidationError() throws Exception {
+        assertTrue(testController.events().isEmpty());
+        var flinkDeployment = TestUtils.buildApplicationCluster();
+        flinkDeployment.getSpec().getJob().setParallelism(-1);
+        testController.reconcile(flinkDeployment, context);
+
+        assertEquals(1, testController.events().size());
+        assertEquals(
+                ResourceLifecycleState.FAILED, flinkDeployment.getStatus().getLifecycleState());
+
+        var event = testController.events().remove();
+        assertEquals("Warning", event.getType());

Review Comment:
   In many cases I prefer to spell out these strings in tests. That also directly guards against making breaking changes to easy :) 



##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentControllerTest.java:
##########
@@ -864,6 +872,23 @@ public void testSuccessfulObservationShouldClearErrors() throws Exception {
                 appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
     }
 
+    @Test
+    public void testValidationError() throws Exception {
+        assertTrue(testController.events().isEmpty());
+        var flinkDeployment = TestUtils.buildApplicationCluster();
+        flinkDeployment.getSpec().getJob().setParallelism(-1);
+        testController.reconcile(flinkDeployment, context);
+
+        assertEquals(1, testController.events().size());
+        assertEquals(
+                ResourceLifecycleState.FAILED, flinkDeployment.getStatus().getLifecycleState());
+
+        var event = testController.events().remove();
+        assertEquals("Warning", event.getType());

Review Comment:
   In many cases I prefer to spell out these strings in tests. That also directly guards against making breaking changes too easy :) 



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #342: [FLINK-28846] Trigger event on validation error

Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #342:
URL: https://github.com/apache/flink-kubernetes-operator/pull/342#discussion_r940972323


##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentControllerTest.java:
##########
@@ -864,6 +872,23 @@ public void testSuccessfulObservationShouldClearErrors() throws Exception {
                 appCluster.getStatus().getReconciliationStatus().getLastStableSpec());
     }
 
+    @Test
+    public void testValidationError() throws Exception {
+        assertTrue(testController.events().isEmpty());
+        var flinkDeployment = TestUtils.buildApplicationCluster();
+        flinkDeployment.getSpec().getJob().setParallelism(-1);
+        testController.reconcile(flinkDeployment, context);
+
+        assertEquals(1, testController.events().size());
+        assertEquals(
+                ResourceLifecycleState.FAILED, flinkDeployment.getStatus().getLifecycleState());
+
+        var event = testController.events().remove();
+        assertEquals("Warning", event.getType());

Review Comment:
   :) LGTM anyway, +1 for merging



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-kubernetes-operator] gyfora merged pull request #342: [FLINK-28846] Trigger event on validation error

Posted by GitBox <gi...@apache.org>.
gyfora merged PR #342:
URL: https://github.com/apache/flink-kubernetes-operator/pull/342


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink-kubernetes-operator] morhidi commented on pull request #342: [FLINK-28846] Trigger event on validation error

Posted by GitBox <gi...@apache.org>.
morhidi commented on PR #342:
URL: https://github.com/apache/flink-kubernetes-operator/pull/342#issuecomment-1208987995

   Thank @gyfora this was indeed missing.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org