gyfora commented on code in PR #196:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/196#discussion_r867443705


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/ReconciliationUtils.java:
##########
@@ -255,4 +257,34 @@ public static boolean shouldRollBack(
                 .minus(readinessTimeout)
                 
.isAfter(Instant.ofEpochMilli(reconciliationStatus.getReconciliationTimestamp()));
     }
+
+    public static <
+                    SPEC extends AbstractFlinkSpec,
+                    STATUS extends CommonStatus<SPEC>,
+                    CR extends CustomResource<SPEC, STATUS>>
+            boolean applyValidationErrorAndResetSpec(
+                    CR deployment, CommonStatus<?> prevStatus, String newErr) {
+
+        if (!newErr.equals(prevStatus.getError())) {
+            LOG.error("Validation failed: " + newErr);
+        }
+
+        ReconciliationUtils.updateForReconciliationError(deployment, newErr);
+
+        var lastReconciledSpec =
+                
deployment.getStatus().getReconciliationStatus().deserializeLastReconciledSpec();
+        if (lastReconciledSpec == null) {
+            // Validation failed before anything was deployed, nothing to do
+            return false;
+        } else {
+            // We need to observe/reconcile using the last version of the 
deployment spec
+            deployment.setSpec(lastReconciledSpec);

Review Comment:
   I wish we could always use the webhook but even in our environments it’s not 
always possible due to access limitations.



-- 
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