Skip to content
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

[STRMCMP-616] Use error retrying system for savepoint errors during deletion #87

Merged
merged 5 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integ/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export OPERATOR_IMAGE=127.0.0.1:32000/flinkk8soperator:local
umask 000

cd $(dirname "$0")
go test -timeout 22m -check.vv IntegSuite
go test -timeout 30m -check.vv IntegSuite

2 changes: 1 addition & 1 deletion integ/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (f *TestUtil) CreateCRD() error {

func (f *TestUtil) CreateOperator() error {
configValue := make(map[string]string)
configValue["development"] = "operator:\n containerNameFormat: \"%s-unknown\"\n resyncPeriod: 5s\n baseBackoffDuration: 10ms\n maxBackoffDuration: 50ms\n maxErrDuration: 40s\n "
configValue["development"] = "operator:\n containerNameFormat: \"%s-unknown\"\n resyncPeriod: 5s\n baseBackoffDuration: 50ms\n maxBackoffDuration: 2s\n maxErrDuration: 40s\n "

configMap := v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/flinkapplication/flink_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flinkapplication

import (
"context"
"math"
"time"

"k8s.io/client-go/tools/record"
Expand Down Expand Up @@ -676,6 +677,8 @@ func (s *FlinkStateMachine) handleApplicationDeleting(ctx context.Context, app *
fmt.Sprintf("Failed to take savepoint %v", status.Operation.FailureCause))
// clear the trigger id so that we can try again
app.Spec.SavepointInfo.TriggerID = ""
return true, client.GetRetryableError(errors.New("failed to take savepoint"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a unit test ?

client.CancelJobWithSavepoint, "500", math.MaxInt32)
} else if status.SavepointStatus.Status == client.SavePointCompleted {
// we're done, clean up
s.flinkController.LogEvent(ctx, app, corev1.EventTypeNormal, "CanceledJob",
Expand Down
28 changes: 25 additions & 3 deletions pkg/controller/flinkapplication/flink_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,10 @@ func TestDeleteWithSavepoint(t *testing.T) {
if updateCount == 1 {
assert.Equal(t, triggerID, application.Spec.SavepointInfo.TriggerID)
} else if updateCount == 2 {
assert.Equal(t, savepointPath, application.Spec.SavepointInfo.SavepointLocation)
assert.NotNil(t, application.Status.LastSeenError)
} else if updateCount == 3 {
assert.Equal(t, savepointPath, application.Spec.SavepointInfo.SavepointLocation)
} else if updateCount == 4 {
assert.Equal(t, 0, len(app.Finalizers))
}

Expand All @@ -717,7 +719,23 @@ func TestDeleteWithSavepoint(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 2, updateCount)

savepointStatusCount := 0
mockFlinkController.GetSavepointStatusFunc = func(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (*client.SavepointResponse, error) {
savepointStatusCount++

if savepointStatusCount == 1 {
return &client.SavepointResponse{
SavepointStatus: client.SavepointStatusResponse{
Status: client.SavePointCompleted,
},
Operation: client.SavepointOperationResponse{
FailureCause: client.FailureCause{
Class: "java.util.concurrent.CompletionException",
StackTrace: "Exception",
},
},
}, nil
}
return &client.SavepointResponse{
SavepointStatus: client.SavepointStatusResponse{
Status: client.SavePointCompleted,
Expand All @@ -728,10 +746,14 @@ func TestDeleteWithSavepoint(t *testing.T) {
}, nil
}

// the first time we return an error from the savepointing status
err = stateMachineForTest.Handle(context.Background(), app.DeepCopy())
assert.Error(t, err)

err = stateMachineForTest.Handle(context.Background(), &app)
assert.NoError(t, err)

assert.Equal(t, 3, updateCount)
assert.Equal(t, 4, updateCount)

mockFlinkController.GetJobsForApplicationFunc = func(ctx context.Context, application *v1beta1.FlinkApplication, hash string) (jobs []client.FlinkJob, err error) {
return []client.FlinkJob{
Expand All @@ -745,7 +767,7 @@ func TestDeleteWithSavepoint(t *testing.T) {
err = stateMachineForTest.Handle(context.Background(), &app)
assert.NoError(t, err)

assert.Equal(t, 4, updateCount)
assert.Equal(t, 5, updateCount)

}

Expand Down