gyfora commented on code in PR #1043:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/1043#discussion_r4697100600
##########
docs/content.zh/docs/managing/bluegreen-deployments.md:
##########
@@ -160,8 +167,150 @@ If the grace period expires first, the transition is
aborted:
The abort mechanism ensures that a failed deployment does not disrupt
production traffic, while everything needed to investigate what went wrong with
the attempted deployment stays in place.
+In the `ADVANCED` transition mode the gate adds a deadline of its own and one
more step to an abort, both covered under [Aborts](#aborts).
+
Recovery is then an ordinary next upgrade: inspect the suspended child for the
root cause, correct the template, and apply it. The next spec change starts a
fresh transition that redeploys the same color from the corrected spec.
+## Advanced Transition Mode
+
+{{< hint warning >}}
+Like blue/green deployments as a whole, the `ADVANCED` transition mode is
experimental.
+{{< /hint >}}
+
+In the `ADVANCED` transition mode the operator injects a gate operator into
the jobs of both deployments. Both jobs read the same input, so every record
reaches both gates, and the gates decide which of the two jobs writes it. The
jobs coordinate through the resource's ConfigMap, and the controller retires
the old deployment only once its gate has handed everything over.
+
+### How the Hand-Over Works
+
+The gates use two kinds of time:
+
+- **The job's watermark**, produced by its `WatermarkStrategy` (or the
`WATERMARK FOR` clause in SQL), drives the gates. When the new deployment is
ready, the old deployment's gate proposes its own watermark plus the deployment
deletion delay as the cutover point. Every subtask of that gate may propose
one, the first written to the ConfigMap wins and all of them use it. The old
deployment stops writing once its watermark passes the cutover point, and the
new deployment writes every record once its own watermark passes it. Until the
cutover point is set, the old deployment writes every record, including those
up to the job's out-of-orderness ahead of its watermark, so the deployment
deletion delay must be at least that out-of-orderness, or the new deployment
writes those records again. `ADVANCED` therefore rejects a resource that leaves
the delay unset; `0ms` is only right for a job whose event times never go
backwards.
+- **Each record's timestamp**, read by the extraction strategy the job
configures, decides who writes the record until then: the old deployment writes
records older than the cutover point, the new deployment the rest.
+
+What this gives you:
+
+- Every record that arrives within the job's watermark is written exactly once.
+- Late records are written by the old deployment before the crossing and by
the new deployment after it. Only late records arriving right around the
crossing can be written twice or dropped, because the watermarks of the two
jobs do not advance in lockstep.
+- A record without a timestamp (a null field or column, or an extractor
returning `null`) counts as older than the cutover point: the old deployment
writes it before the crossing, the new deployment after.
+
+Both kinds of time must be the same event time: the extracted timestamp must
be the epoch milliseconds of the time the watermark is built from. The gates
never use the wall clock. A job without event-time watermarks never gets a
cutover point, and the transition is aborted once the gate timeout expires.
+
+#### Teardown
+
+The first subtask of the old gate whose watermark passes the cutover point
signals that the old deployment may be retired, but its other subtasks may
still have records to write: without a shuffle in front of the gate, each
subtask follows only its own upstream. Each gate subtask therefore reports a
`bluegreenGateHandOverDone` gauge, 1 once its watermark has passed the cutover
point, or once it has received no record for 30 seconds since it learned the
cutover point. The controller reads the minimum of that gauge over all subtasks
through the Flink REST API and waits until it is 1.
+
+The old deployment is then suspended with a savepoint, whatever its upgrade
mode, and deleted once stopped. The savepoint makes sinks that commit on
checkpoints, such as transactional Kafka or file sinks, commit what the old
deployment wrote since its last checkpoint: deleting a running job would cancel
it and discard that output, and the new deployment does not write those records
again. Without a savepoint directory the old deployment is deleted directly,
with a warning in the operator log.
+
+#### Aborts
+
+The gate phase, from the moment the new deployment is ready until every
subtask of the old gate is done, is bounded by
`kubernetes.operator.bluegreen.gate.timeout`. If the hand-over does not
complete in that time, because a watermark stalls or the new deployment keeps
failing for example, the transition is aborted as described under [Health
Monitoring and Recovery](#health-monitoring-and-recovery), and the gate of the
deployment that keeps serving is reset so that it passes every record again.
What else happens depends on how far the hand-over got:
+
+- Before the cutover point is set, the old deployment was still writing every
record and simply carries on.
+- Once it is set, the old deployment had left the records from it on to the
new one, which may not have written or committed them. The old deployment is
therefore redeployed from the savepoint the new deployment started from,
through its `savepointRedeployNonce`, so those records are written again.
Records written since the transition started may be written twice.
+
+### ADVANCED Requirements
+
+- **A Java 17 JobManager**: the gate is injected by a Java agent compiled to
Java 17 bytecode and loaded at JobManager startup, so a Java 11 JobManager
fails to start with `UnsupportedClassVersionError`. `BASIC` deployments are not
affected.
Review Comment:
I think we want to remove the injection logic from 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]