Skip to content

Commit 6fadd2c

Browse files
authored
fix(helm): synchronize FlinkCluster CRD schema (#1027)
Refresh the Helm CRD from the canonical generated schema so Helm installs no longer persist a CANONICAL savepoint format by default. Add a CI consistency gate and document upgrade behavior for existing resources.
1 parent 35ccff2 commit 6fadd2c

3 files changed

Lines changed: 1321 additions & 69 deletions

File tree

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
5252
generate-crd-docs: crd-ref-docs ## Generate CRD documentation to docs/crd.md
5353
$(CRD_REF_DOCS) --source-path=./apis/flinkcluster/v1beta1 --config=docs/config.yaml --renderer=markdown --output-path=docs/crd.md
5454

55+
.PHONY: verify-helm-crd-schema
56+
verify-helm-crd-schema: kustomize ## Verify the Helm CRD schema matches the generated CRD.
57+
@set -euo pipefail; \
58+
tmp_dir=$$(mktemp -d); \
59+
trap 'rm -rf "$$tmp_dir"' EXIT; \
60+
$(KUSTOMIZE) build config/default | \
61+
yq -o=json -I=2 'select(.kind == "CustomResourceDefinition" and .metadata.name == "flinkclusters.flinkoperator.k8s.io") | .spec.versions[] | select(.name == "v1beta1") | .schema.openAPIV3Schema | sort_keys(..)' - > "$$tmp_dir/generated.json"; \
62+
sed -E 's/\{\{[^}]+\}\}/helm-value/g' helm-chart/flink-operator/templates/flink-cluster-crd.yaml | \
63+
yq -o=json -I=2 '.spec.versions[] | select(.name == "v1beta1") | .schema.openAPIV3Schema | sort_keys(..)' - > "$$tmp_dir/helm.json"; \
64+
grep -q '^{' "$$tmp_dir/generated.json" && grep -q '^{' "$$tmp_dir/helm.json" || { \
65+
echo "Failed to extract the v1beta1 OpenAPI schema for comparison." >&2; \
66+
exit 1; \
67+
}; \
68+
diff -u "$$tmp_dir/generated.json" "$$tmp_dir/helm.json" || { \
69+
echo "Helm CRD schema is out of sync. Run 'cd helm-chart/flink-operator && ./update_template.sh' and commit the refreshed CRD template." >&2; \
70+
exit 1; \
71+
}
72+
5573
tidy: ## Run go mod tidy
5674
go mod tidy
5775

@@ -63,6 +81,7 @@ vet: ## Run go vet against code.
6381

6482
.PHONY: test
6583
test: manifests generate fmt vet tidy kustomize envtest ## Run tests.
84+
$(MAKE) verify-helm-crd-schema
6685
rm -rf config/test && mkdir -p config/test/crd
6786
$(KUSTOMIZE) build config/crd > config/test/crd/flinkoperator.k8s.io_flinkclusters.yaml
6887
KUBEBUILDER_ASSETS=$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path) go test ./... -coverprofile cover.out

docs/savepoints_guide.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,12 @@ savepoints in GCS.
245245
## Savepoint format
246246

247247
Flink supports two savepoint formats: `CANONICAL` and `NATIVE`. You can control which format is used by setting the
248-
`savepointFormatType` property in the job spec. If not specified, Flink uses the canonical format by default. This option
249-
requires Flink 1.15 or later; for older or unparseable Flink versions, the operator omits the format parameter.
248+
`savepointFormatType` property in the job spec. If it is omitted, the operator omits the REST format parameter and
249+
`status.savepoint.formatType`, allowing Flink to choose its own default (currently canonical). The operator also omits
250+
this parameter for Flink versions before 1.15 or when the Flink version cannot be parsed.
251+
252+
Removing the CRD default is not retroactive. Clusters created while an older CRD defaulted this field may retain an
253+
explicit `CANONICAL` value in their stored spec until the field is removed or changed.
250254

251255
For more details on the differences between the two formats and when to use each, see the
252256
[Flink documentation on savepoint formats](https://nightlies.apache.org/flink/flink-docs-stable/docs/ops/state/savepoints/#savepoint-format).

0 commit comments

Comments
 (0)