Skip to content

Commit 6313ea0

Browse files
committed
Preserve deep copy of the spec to fix unit tests
1 parent 76b1700 commit 6313ea0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/bluegreen/BlueGreenUtils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,18 @@ public static FlinkDeployment prepareFlinkDeployment(
320320
ObjectMeta bgMeta) {
321321
// Deployment
322322
FlinkDeployment flinkDeployment = new FlinkDeployment();
323-
FlinkBlueGreenDeploymentSpec spec = context.getBgDeployment().getSpec();
323+
FlinkBlueGreenDeploymentSpec originalSpec = context.getBgDeployment().getSpec();
324324

325325
String childDeploymentName =
326326
bgMeta.getName() + "-" + blueGreenDeploymentType.toString().toLowerCase();
327327

328+
// Create a deep copy of the spec to avoid mutating the original
329+
FlinkBlueGreenDeploymentSpec spec =
330+
SpecUtils.readSpecFromJSON(
331+
SpecUtils.writeSpecAsJSON(originalSpec, "spec"),
332+
"spec",
333+
FlinkBlueGreenDeploymentSpec.class);
334+
328335
// The Blue/Green initialSavepointPath is only used for first-time deployments
329336
if (isFirstDeployment) {
330337
String initialSavepointPath =

0 commit comments

Comments
 (0)