feat: remove buntdb dep
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package managed_job
|
||||
|
||||
import (
|
||||
"flink-kube-operator/internal/crd/v1alpha1"
|
||||
"time"
|
||||
|
||||
"gitea.com/logicamp/lc"
|
||||
@@ -30,20 +31,30 @@ func (job *ManagedJob) Cycle() {
|
||||
lc.Logger.Debug("[managed-job] [new] check cycle", zap.String("jobKey", string(job.def.UID)))
|
||||
|
||||
// Init job
|
||||
if job.state == nil {
|
||||
if job.def.Status.JobStatus == "" {
|
||||
err := job.upload()
|
||||
if err != nil {
|
||||
job.setError("[upload-error] " + err.Error())
|
||||
job.crd.Patch(job.def.UID, map[string]interface{}{
|
||||
"status": map[string]interface{}{
|
||||
"error": "[upload-error] " + err.Error(),
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
err = job.run()
|
||||
if err != nil {
|
||||
job.setError("[run-error] " + err.Error())
|
||||
job.crd.Patch(job.def.UID, map[string]interface{}{
|
||||
"status": map[string]interface{}{
|
||||
"error": "[run-error] " + err.Error(),
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
job.crd.SetJobStatus(job.def.UID, string(job.state.Status))
|
||||
// job.crd.SetJobStatus(job.def.UID, v1alpha1.FlinkJobStatus{
|
||||
// JobStatus: job.def.Status.JobStatus,
|
||||
// })
|
||||
|
||||
// Check for set running or error state
|
||||
/* if job.state.Status == JobStatusCreating || job.state.Status == JobStatusFailing {
|
||||
@@ -54,9 +65,9 @@ func (job *ManagedJob) Cycle() {
|
||||
return
|
||||
} */
|
||||
|
||||
if job.state.Status == JobStatusRunning {
|
||||
if (job.def.Spec.SavepointInterval.Duration != 0) && ((job.state.LastSavepointDate == nil) || time.Now().Add(-job.def.Spec.SavepointInterval.Duration).After(*job.state.LastSavepointDate)) {
|
||||
if job.state.SavepointTriggerId == nil {
|
||||
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()
|
||||
@@ -64,10 +75,10 @@ func (job *ManagedJob) Cycle() {
|
||||
}
|
||||
return
|
||||
}
|
||||
if job.state.Status == JobStatusFailed {
|
||||
if job.def.Status.JobStatus == v1alpha1.JobStatusFailed && job.def.Status.LastSavepointPath != nil {
|
||||
job.restore()
|
||||
return
|
||||
}
|
||||
|
||||
lc.Logger.Warn("[managed-job] [cycle]", zap.String("unhanded job status", string(job.state.Status)))
|
||||
lc.Logger.Warn("[managed-job] [cycle]", zap.String("unhanded job status", string(job.def.Status.JobStatus)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user