Skip to content

Commit b03ebae

Browse files
authored
[FLINK-36577] Add compatibility check for FlinkStateSnapshot (#991)
1 parent aa6ef16 commit b03ebae

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

flink-kubernetes-operator-api/pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,23 @@ under the License.
257257
</target>
258258
</configuration>
259259
</execution>
260+
<execution>
261+
<id>statesnapshot-crd-compatibility-check</id>
262+
<phase>package</phase>
263+
<goals>
264+
<goal>run</goal>
265+
</goals>
266+
<configuration>
267+
<target>
268+
<java classname="org.apache.flink.kubernetes.operator.api.validation.CrdCompatibilityChecker"
269+
fork="true" failonerror="true">
270+
<classpath refid="maven.compile.classpath"/>
271+
<arg value="file://${rootDir}/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
272+
<arg value="https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.10.0/helm/flink-kubernetes-operator/crds/flinkstatesnapshots.flink.apache.org-v1.yml"/>
273+
</java>
274+
</target>
275+
</configuration>
276+
</execution>
260277
</executions>
261278
</plugin>
262279
<plugin>

flink-kubernetes-operator-api/src/test/java/org/apache/flink/kubernetes/operator/api/validation/CrdCompatibilityCheckerTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.apache.flink.kubernetes.operator.api.FlinkDeployment;
2121
import org.apache.flink.kubernetes.operator.api.FlinkSessionJob;
22+
import org.apache.flink.kubernetes.operator.api.FlinkStateSnapshot;
2223

2324
import com.fasterxml.jackson.core.JsonProcessingException;
2425
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -271,6 +272,19 @@ public void testCreateFlinkDeploymentIgnoreUnknownFields() throws IOException {
271272
assertEquals(flinkDeploymentWithUnknownFields.toString(), flinkDeployment.toString());
272273
}
273274

275+
@Test
276+
public void testCreateFlinkStateSnapshotIgnoreUnknownFields() throws IOException {
277+
FlinkStateSnapshot flinkSnapshotWithUnknownFields =
278+
objectMapper.readValue(
279+
new File("src/test/resources/test-snapshot-with-unknown-fields.yaml"),
280+
FlinkStateSnapshot.class);
281+
FlinkStateSnapshot flinkSnapshot =
282+
objectMapper.readValue(
283+
new File("src/test/resources/test-snapshot.yaml"),
284+
FlinkStateSnapshot.class);
285+
assertEquals(flinkSnapshotWithUnknownFields.toString(), flinkSnapshot.toString());
286+
}
287+
274288
@Test
275289
public void testGetSchemaFromUrl() throws IOException {
276290
var fileUrl =
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
apiVersion: flink.apache.org/v1beta1
19+
kind: FlinkStateSnapshot
20+
metadata:
21+
name: example-savepoint
22+
spec:
23+
backoffLimit: 0
24+
jobReference:
25+
kind: FlinkDeployment
26+
name: example-deployment
27+
unknownField: testUnknownField
28+
savepoint:
29+
unknownField: testUnknownField
30+
unknownField: testUnknownField
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
apiVersion: flink.apache.org/v1beta1
19+
kind: FlinkStateSnapshot
20+
metadata:
21+
name: example-savepoint
22+
spec:
23+
backoffLimit: 0
24+
jobReference:
25+
kind: FlinkDeployment
26+
name: example-deployment
27+
savepoint: {}

0 commit comments

Comments
 (0)