Ensure the new jar is properly uploaded during an upgrade process. Previously, the jar was not replaced as expected.
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package managed_job
|
|
|
|
import (
|
|
"flink-kube-operator/internal/crd/v1alpha1"
|
|
"time"
|
|
|
|
"flink-kube-operator/pkg"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (job *ManagedJob) Cycle() {
|
|
pkg.Logger.Debug("[managed-job] [new] check cycle", zap.String("jobName", job.def.GetName()))
|
|
|
|
// Init job
|
|
if job.def.Status.LifeCycleStatus == "" && job.def.Status.JobStatus == "" {
|
|
job.run(false)
|
|
return
|
|
}
|
|
|
|
if job.def.Status.JobStatus == v1alpha1.JobStatusFinished && job.def.Status.LifeCycleStatus == v1alpha1.LifeCycleStatusGracefullyPaused {
|
|
job.run(true)
|
|
return
|
|
}
|
|
|
|
if job.def.Status.JobStatus == v1alpha1.JobStatusRunning {
|
|
if (job.def.Spec.SavepointInterval.Duration != 0) && ((job.def.Status.LastSavepointDate == nil) || time.Now().Add(-job.def.Spec.SavepointInterval.Duration).After(*job.def.Status.LastSavepointDate)) {
|
|
if job.def.Status.SavepointTriggerId == nil {
|
|
job.createSavepoint()
|
|
} else {
|
|
job.trackSavepoint()
|
|
}
|
|
}
|
|
if job.def.Status.RunningJarURI != nil && job.def.Spec.JarURI != *job.def.Status.RunningJarURI {
|
|
job.upgrade()
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
if job.def.Status.JobStatus == v1alpha1.JobStatusCreating {
|
|
return
|
|
}
|
|
// if job.def.Status.JobStatus == v1alpha1.JobStatusFailed && job.def.Status.LastSavepointPath != nil {
|
|
// //job.restore()
|
|
// return
|
|
// }
|
|
// if job.def.Status.JobStatus == v1alpha1.JobStatusFailed && job.def.Status.LastSavepointPath == nil {
|
|
// //job.restore()
|
|
// return
|
|
// }
|
|
|
|
pkg.Logger.Warn("[managed-job] [cycle]", zap.String("unhanded job status", string(job.def.Status.JobStatus)))
|
|
}
|