-
Couldn't load subscription status.
- Fork 155
Update with external checkpoints #199
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
base: master
Are you sure you want to change the base?
Changes from all commits
d92696a
0552fe9
c108c8e
0969f49
5c15785
84e650e
7b4e12d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,9 @@ type ControllerInterface interface { | |
| // able to savepoint for some reason. | ||
| FindExternalizedCheckpoint(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (string, error) | ||
|
|
||
| // Ensures that application is configured to externalize and *not* delete checkpoints on cancel. | ||
| FindExternalizedCheckpointForSavepoint(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (string, error) | ||
|
|
||
| // Logs an event to the FlinkApplication resource and to the operator log | ||
| LogEvent(ctx context.Context, app *v1beta1.FlinkApplication, eventType string, reason string, message string) | ||
|
|
||
|
|
@@ -468,8 +471,8 @@ func (f *Controller) DeleteOldResourcesForApp(ctx context.Context, app *v1beta1. | |
| return nil | ||
| } | ||
|
|
||
| func (f *Controller) FindExternalizedCheckpoint(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (string, error) { | ||
| checkpoint, err := f.flinkClient.GetLatestCheckpoint(ctx, f.getURLFromApp(application, hash), f.GetLatestJobID(ctx, application)) | ||
| func (f *Controller) findExternalizedCheckpoint(ctx context.Context, application *v1beta1.FlinkApplication, hash string, checkpointMaxAge int32) (string, error) { | ||
| checkpoint, err := f.flinkClient.GetLatestCheckpoint(ctx, f.getURLFromApp(application, hash), application.Status.JobStatus.JobID) | ||
| var checkpointPath string | ||
| var checkpointTime int64 | ||
| if err != nil { | ||
|
|
@@ -490,12 +493,28 @@ func (f *Controller) FindExternalizedCheckpoint(ctx context.Context, application | |
| return "", nil | ||
| } | ||
|
|
||
| if isCheckpointOldToRecover(checkpointTime, getMaxCheckpointRestoreAgeSeconds(application)) { | ||
| if isCheckpointOldToRecover(checkpointTime, checkpointMaxAge) { | ||
| logger.Info(ctx, "Found checkpoint to restore from, but was too old") | ||
| return "", nil | ||
| } | ||
|
|
||
| return checkpointPath, nil | ||
|
|
||
| } | ||
|
|
||
| func (f *Controller) FindExternalizedCheckpoint(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (string, error) { | ||
| return f.findExternalizedCheckpoint(ctx, application, hash, getMaxCheckpointRestoreAgeSeconds(application)) | ||
| } | ||
|
|
||
| func (f *Controller) FindExternalizedCheckpointForSavepoint(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (string, error) { | ||
| checkpointConfig, err := f.flinkClient.GetCheckpointConfig(ctx, f.getURLFromApp(application, hash), application.Status.JobStatus.JobID) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there opportunity to combine |
||
| if err != nil { | ||
| return "", err | ||
| } | ||
| if checkpointConfig.Externalization.Enabled && !checkpointConfig.Externalization.DeleteOnCancellation { | ||
| return "", fmt.Errorf("Checkpoint configuration not compatable for starting from checkpoints") | ||
| } | ||
| return f.findExternalizedCheckpoint(ctx, application, hash, getMaxCheckpointRestoreAgeSeconds(application)) | ||
| } | ||
|
|
||
| func isCheckpointOldToRecover(checkpointTime int64, maxCheckpointRecoveryAgeSec int32) bool { | ||
|
|
||
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 love
go fmt, but it can also be disruptive causing PR's to bloat changes and hides the actual diff.I could add some line breaks to separate out the new, longer struct member and minimize the line change count on things like this.
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.
Agreed. Not a problem, ok to leave as is :)