From f08d1f4235868749f2710e57ad2001ab269784fa Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Tue, 30 Apr 2024 07:13:01 +0000 Subject: [PATCH 1/2] move validation of storage.scheme and storage.baseDir must be set when upgradeMode is not stateless to helpers Signed-off-by: Casper Thygesen --- charts/flink-job/ci/bad-upgrademode.yaml | 36 ++++++ charts/flink-job/templates/_helpers.tpl | 3 + charts/flink-job/values.schema.json | 133 ----------------------- 3 files changed, 39 insertions(+), 133 deletions(-) create mode 100644 charts/flink-job/ci/bad-upgrademode.yaml diff --git a/charts/flink-job/ci/bad-upgrademode.yaml b/charts/flink-job/ci/bad-upgrademode.yaml new file mode 100644 index 00000000..c378934c --- /dev/null +++ b/charts/flink-job/ci/bad-upgrademode.yaml @@ -0,0 +1,36 @@ +# example values from docs.cheetah.trifork.dev/ +image: + repository: flink + tag: 1.16 +ingress: + enabled: true + hostname: flink.cheetah.trifork.dev + annotations: + cert-manager.io/cluster-issuer: letsencrypt + tlsSecret: letsencrypt + + +version: v1_16 +job: + jarURI: local:///opt/flink/examples/streaming/StateMachineExample.jar + entryClass: org.apache.flink.streaming.examples.statemachine.StateMachineExample + parallelism: 2 + upgradeMode: savepoint + topics: + - name: test + type: input + postfix: postfix +taskManager: + replicas: 2 + resource: + memory: 2Gb + cpu: 0.5 +jobManager: + replicas: 2 + +flinkConfiguration: + state.backend: "rocksdb" + restart-strategy.failure-rate.failure-rate-interval: "6 min" + +metrics: + enabled: true diff --git a/charts/flink-job/templates/_helpers.tpl b/charts/flink-job/templates/_helpers.tpl index 3697c885..5577dada 100644 --- a/charts/flink-job/templates/_helpers.tpl +++ b/charts/flink-job/templates/_helpers.tpl @@ -269,6 +269,9 @@ Validate the configuration */}} {{- define "flink-job.storageConfiguration" -}} {{- $configs := .configs -}} + {{- if and (not (eq .global.job.upgradeMode "stateless")) (not (and .global.storage.scheme .global.storage.baseDir)) -}} + {{- fail "storage.scheme and storage.baseDir must be set when upgradeMode is not stateless" -}} + {{- end -}} {{- if and .global.storage.scheme .global.storage.baseDir (has .global.job.upgradeMode (list "last-state" "savepoint")) -}} {{- $checkpointsDir := printf "%s://%s/%s/checkpoints" (trimSuffix "://" .global.storage.scheme) .global.storage.baseDir .fullname -}} {{- $configs = fromJson (include "flink-job._dictSet" (list $configs "state.checkpoints.dir" $checkpointsDir)) -}} diff --git a/charts/flink-job/values.schema.json b/charts/flink-job/values.schema.json index cfc610c8..73c6f452 100644 --- a/charts/flink-job/values.schema.json +++ b/charts/flink-job/values.schema.json @@ -3,139 +3,6 @@ "title": "JSON schema for flink-job/values.yaml", "type": "object", "additionalProperties": false, - "allOf": [ - { - "if": { - "properties": { - "job": { - "properties": { - "upgradeMode": { - "const": "savepoint" - } - } - } - } - }, - "then": { - "anyOf": [ - { - "properties": { - "flinkConfiguration": { - "required": [ - "state.savepoints.dir" - ] - } - } - }, - { - "properties": { - "storage": { - "type": "object", - "properties": { - "scheme": { - "type": "string", - "minLength": 1 - }, - "baseDir": { - "type": "string", - "minLength": 1 - } - } - } - } - } - ] - } - }, - { - "if": { - "properties": { - "job": { - "properties": { - "upgradeMode": { - "const": "last-state" - } - } - } - } - }, - "then": { - "anyOf": [ - { - "properties": { - "flinkConfiguration": { - "required": [ - "state.checkpoints.dir", - "high-availability.storageDir" - ] - } - } - }, - { - "properties": { - "storage": { - "type": "object", - "properties": { - "scheme": { - "type": "string", - "minLength": 1 - }, - "baseDir": { - "type": "string", - "minLength": 1 - } - } - } - } - } - ] - } - }, - { - "if": - { - "properties": { - "jobManager": { - "properties": { - "replicas": { - "exclusiveMinimum": 1 - } - } - } - } - }, - "then": { - "anyOf": [ - { - "properties": { - "flinkConfiguration": { - "required": [ - "high-availability.storageDir" - ] - } - } - }, - { - "properties": { - "storage": { - "type": "object", - "properties": { - "scheme": { - "type": "string", - "minLength": 1 - }, - "baseDir": { - "type": "string", - "minLength": 1 - } - } - } - } - } - ] - } - } - ], "properties": { "nameOverride": { "type": "string" From f56a212d5f627f35dbc8e5aeded76cb5c1b4ab17 Mon Sep 17 00:00:00 2001 From: Casper Thygesen Date: Tue, 30 Apr 2024 07:15:59 +0000 Subject: [PATCH 2/2] move manual test Signed-off-by: Casper Thygesen --- charts/flink-job/{ci => manual-ci}/bad-upgrademode.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename charts/flink-job/{ci => manual-ci}/bad-upgrademode.yaml (100%) diff --git a/charts/flink-job/ci/bad-upgrademode.yaml b/charts/flink-job/manual-ci/bad-upgrademode.yaml similarity index 100% rename from charts/flink-job/ci/bad-upgrademode.yaml rename to charts/flink-job/manual-ci/bad-upgrademode.yaml