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


##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/reconciler/deployment/ApplicationReconciler.java:
##########
@@ -111,12 +114,34 @@ public void reconcile(FlinkDeployment flinkApp, Context 
context, Configuration e
             }
             IngressUtils.updateIngressRules(flinkApp, effectiveConfig, 
kubernetesClient);
             ReconciliationUtils.updateForSpecReconciliationSuccess(flinkApp, 
stateAfterReconcile);
+        } else if (ReconciliationUtils.shouldRollBack(flinkApp)) {
+            rollbackApplication(flinkApp);
         } else if (SavepointUtils.shouldTriggerSavepoint(flinkApp) && 
isJobRunning(flinkApp)) {
             triggerSavepoint(flinkApp, effectiveConfig);
             ReconciliationUtils.updateSavepointReconciliationSuccess(flinkApp);
         }
     }
 
+    private void rollbackApplication(FlinkDeployment flinkApp) throws 
Exception {
+        LOG.warn("Rolling back deployment to last stable spec");
+        Configuration rollbackConfig =
+                FlinkUtils.getEffectiveConfig(
+                        flinkApp.getMetadata(),
+                        
flinkApp.getStatus().getReconciliationStatus().deserializeLastStableSpec(),
+                        defaultConfig.getFlinkConfig());
+        suspendJob(flinkApp, UpgradeMode.LAST_STATE, rollbackConfig);
+        deployFlinkJob(
+                flinkApp,
+                rollbackConfig,
+                Optional.ofNullable(
+                                flinkApp.getStatus()
+                                        .getJobStatus()
+                                        .getSavepointInfo()
+                                        .getLastSavepoint())
+                        .map(Savepoint::getLocation));
+        flinkApp.getStatus().getReconciliationStatus().setRolledBack(true);

Review Comment:
   Yes, this way it is clear from the status what happened.



-- 
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-unsubscr...@flink.apache.org

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

Reply via email to