milindl commented on code in PR #1168:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/1168#discussion_r3702980163
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/JobStatusObserver.java:
##########
@@ -373,6 +374,31 @@ private static void markSuspended(AbstractFlinkResource<?,
?> resource) {
});
}
+ /**
+ * When a suspend is executed through an asynchronous cancellation the
reconciler exits early
+ * and leaves the resource in the UPGRADING state until the cancellation
completes. Once the job
+ * has ended there is nothing left to do for a suspend request, so we
complete the upgrade here,
+ * otherwise the resource would report the UPGRADING lifecycle state
indefinitely.
+ *
+ * <p>Must be called right after {@link
#markSuspended(AbstractFlinkResource)}, which records
+ * the suspended job state that this completion makes stable.
+ *
+ * @param resource The Flink resource whose cancellation was just observed.
+ */
+ private static void finalizeSuspendedUpgrade(AbstractFlinkResource<?, ?>
resource) {
+ var reconciliationStatus =
resource.getStatus().getReconciliationStatus();
+ var job = resource.getSpec().getJob();
+ if (reconciliationStatus.getState() != ReconciliationState.UPGRADING
+ || job == null
+ || job.getState() != JobState.SUSPENDED) {
Review Comment:
The first one is not needed, we would not get here with job == null. I will
remove it.
The second one (covered by
`testUpgradeNotCompletedWhenTargetStateStillRunning`) is needed if the
situation is a change of the spec which is not suspension, something like a
parallelism change.
It eventually works, but some of the state transitions to get there are not
correct (the session job is marked suspended for a while). Which I thought we
should avoid because they're changing the publicly visible behaviour.
--
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]