-
Notifications
You must be signed in to change notification settings - Fork 498
[FLINK-37370] [Observer] Fix exception caught when handling checkpointing not enabled for batch jobs and add batch e2e test #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gyfora
merged 3 commits into
apache:main
from
Shopify:lc.checkpointing-not-enabled-exception-fix
Mar 16, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| ################################################################################ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ################################################################################ | ||
|
|
||
| apiVersion: flink.apache.org/v1beta1 | ||
| kind: FlinkDeployment | ||
| metadata: | ||
| namespace: default | ||
| name: flink-example-wordcount-batch | ||
| spec: | ||
| image: flink:1.20 | ||
| flinkVersion: v1_20 | ||
| ingress: | ||
| template: "/{{namespace}}/{{name}}(/|$)(.*)" | ||
| className: "nginx" | ||
| annotations: | ||
| nginx.ingress.kubernetes.io/rewrite-target: "/$2" | ||
| flinkConfiguration: | ||
| taskmanager.numberOfTaskSlots: "2" | ||
| kubernetes.operator.snapshot.resource.enabled: "false" | ||
| serviceAccount: flink | ||
| podTemplate: | ||
| spec: | ||
| initContainers: | ||
| - name: artifacts-fetcher | ||
| image: busybox:1.35.0 | ||
| imagePullPolicy: IfNotPresent | ||
| # Use wget or other tools to get user jars from remote storage | ||
| command: [ 'wget', 'STREAMING_EXAMPLES_JAR_URL', '-O', '/flink-artifact/myjob.jar' ] | ||
| volumeMounts: | ||
| - mountPath: /flink-artifact | ||
| name: flink-artifact | ||
| containers: | ||
| # Do not change the main container name | ||
| - name: flink-main-container | ||
| resources: | ||
| requests: | ||
| ephemeral-storage: 2048Mi | ||
| limits: | ||
| ephemeral-storage: 2048Mi | ||
| volumeMounts: | ||
| - mountPath: /opt/flink/usrlib | ||
| name: flink-artifact | ||
| volumes: | ||
| - name: flink-artifact | ||
| emptyDir: { } | ||
| jobManager: | ||
| resource: | ||
| memory: "1024m" | ||
| cpu: 0.5 | ||
| taskManager: | ||
| resource: | ||
| memory: "1Gi" | ||
| cpu: 0.5 | ||
| job: | ||
| jarURI: local:///opt/flink/usrlib/myjob.jar | ||
| entryClass: org.apache.flink.streaming.examples.wordcount.WordCount | ||
| args: ["--execution-mode", "BATCH"] | ||
| parallelism: 2 | ||
| upgradeMode: stateless | ||
| mode: native | ||
|
|
||
| --- | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: IngressClass | ||
| metadata: | ||
| annotations: | ||
| ingressclass.kubernetes.io/is-default-class: "true" | ||
| labels: | ||
| app.kubernetes.io/component: controller | ||
| name: nginx | ||
| spec: | ||
| controller: k8s.io/ingress-nginx | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bash | ||
| ################################################################################ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ################################################################################ | ||
|
|
||
| # This script tests basic Flink batch job operations on Kubernetes: | ||
| # 1. Deploys a FlinkDeployment for a batch job. | ||
| # 2. Waits for the JobManager to become ready. | ||
| # 3. Verifies that the job reaches the FINISHED state. | ||
| # 4. Applies a no-op spec change and verifies the job remains in the FINISHED state. | ||
| # 5. Checks the operator logs for the expected job state transition message. | ||
| # 6. Checks the JobManager logs for successful application completion. | ||
| # 7. Applies a spec change and verifies the job re-runs successfully. | ||
| SCRIPT_DIR=$(dirname "$(readlink -f "$0")") | ||
| source "${SCRIPT_DIR}/utils.sh" | ||
|
|
||
| CLUSTER_ID="flink-example-wordcount-batch" | ||
| APPLICATION_YAML="${SCRIPT_DIR}/data/flinkdep-batch-cr.yaml" | ||
| APPLICATION_IDENTIFIER="flinkdep/$CLUSTER_ID" | ||
| TIMEOUT=300 | ||
|
|
||
| on_exit cleanup_and_exit "$APPLICATION_YAML" $TIMEOUT $CLUSTER_ID | ||
|
|
||
| retry_times 5 30 "kubectl apply -f $APPLICATION_YAML" || exit 1 | ||
|
|
||
| wait_for_jobmanager_running $CLUSTER_ID $TIMEOUT | ||
|
|
||
| # Wait for the job to reach the FINISHED state. | ||
| wait_for_status $APPLICATION_IDENTIFIER '.status.jobStatus.state' FINISHED $TIMEOUT || exit 1 | ||
|
|
||
| # Apply a no-op spec change; verify the job remains in the FINISHED state. | ||
| kubectl patch flinkdep ${CLUSTER_ID} --type merge --patch '{"spec":{"flinkConfiguration": {"kubernetes.operator.deployment.readiness.timeout": "6h" } } }' | ||
| wait_for_status $APPLICATION_IDENTIFIER '.status.jobStatus.state' FINISHED $TIMEOUT || exit 1 | ||
|
|
||
| # Verify the job status change to FINISHED shows up in the operator logs. | ||
| operator_pod_name=$(get_operator_pod_name) | ||
| wait_for_operator_logs "$operator_pod_name" "Job status changed from .* to FINISHED" ${TIMEOUT} || exit 1 | ||
|
|
||
| # Verify the job completed successfully in the job manager logs. | ||
| jm_pod_name=$(get_jm_pod_name $CLUSTER_ID) | ||
| wait_for_logs "$jm_pod_name" "Application completed SUCCESSFULLY" ${TIMEOUT} || exit 1 | ||
|
|
||
| # Apply a spec change; verify the job re-runs and reaches the FINISHED state. | ||
| kubectl patch flinkdep ${CLUSTER_ID} --type merge --patch '{"spec":{"job": {"parallelism": 1 } } }' | ||
| wait_for_status $APPLICATION_IDENTIFIER '.status.jobStatus.state' RECONCILING $TIMEOUT || exit 1 | ||
| wait_for_status $APPLICATION_IDENTIFIER '.status.jobStatus.state' FINISHED $TIMEOUT || exit 1 | ||
|
|
||
| echo "Successfully ran the batch job test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set this to last-state?
I feel that with stateless we won't be able to verify that the savepoint observe logic is successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could. Although the operator logic still reaches
getLastCheckpointeven instatelessmode. Does last-state even make sense for batch jobs given they don't support checkpointing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right, we could leave this in stateless. To avoid sleeping and make sure that is reconciled and stays in finished we can simply add a no-op spec change (such as change some operator config that doesn't result in a new job depoyment) or changing of the upgrade mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gyfora Makes sense. Updated.