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

Make sure application mode clusters aren't stuck in status updating #710

Merged
merged 2 commits into from
Aug 17, 2023
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
10 changes: 10 additions & 0 deletions controllers/flinkcluster/flinkcluster_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,15 @@ func (reconciler *ClusterReconciler) reconcileJob(ctx context.Context) (ctrl.Res
if err != nil {
return requeueResult, err
}
} else if observedSubmitter.Status.Failed >= 1 {
log.Info("Found failed job submitter")
err = reconciler.deleteJob(ctx, observedSubmitter)
if err != nil {
return requeueResult, err
}
} else {
log.Info("Found job submitter, wait for it to be active or failed")
return requeueResult, nil
}
} else {
err = reconciler.createJob(ctx, desiredJob)
Expand Down Expand Up @@ -567,6 +576,7 @@ func (reconciler *ClusterReconciler) createJob(ctx context.Context, job *batchv1
} else {
log.Info("Job submitter created")
}

return err
}

Expand Down
12 changes: 8 additions & 4 deletions controllers/flinkcluster/flinkcluster_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ package flinkcluster
import (
"encoding/json"
"fmt"
batchv1 "k8s.io/api/batch/v1"
"reflect"
"time"

batchv1 "k8s.io/api/batch/v1"

"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -659,10 +660,13 @@ func (updater *ClusterStatusUpdater) deriveJobStatus(ctx context.Context) *v1bet
newJobState = v1beta1.JobStatePending
case shouldUpdateJob(&observed):
newJobState = v1beta1.JobStateUpdating
case oldJob.ShouldRestart(jobSpec):
newJobState = v1beta1.JobStateRestarting
case oldJob.IsStopped():
newJobState = oldJob.State
// When a new job is deploying, update the job state to deploying.
if observedSubmitter.job != nil && (observedSubmitter.job.Status.Active == 1 || isJobInitialising(observedSubmitter.job.Status)) {
newJobState = v1beta1.JobStateDeploying
} else {
newJobState = oldJob.State
}
case oldJob.IsPending() && oldJob.DeployTime != "":
newJobState = v1beta1.JobStateDeploying
// Derive the job state from the observed Flink job, if it exists.
Expand Down
4 changes: 4 additions & 0 deletions controllers/flinkcluster/flinkcluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,7 @@ func GenJobId(cluster *v1beta1.FlinkCluster) (string, error) {
hash := md5.Sum([]byte(cluster.Status.Revision.NextRevision))
return hex.EncodeToString(hash[:]), nil
}

func isJobInitialising(jobStatus batchv1.JobStatus) bool {
return jobStatus.Active == 0 && jobStatus.Succeeded == 0 && jobStatus.Failed == 0
}