feat(managed-job): add update job method

This commit is contained in:
2024-12-01 02:05:49 +03:30
parent ac8453bb57
commit fb646086b0
7 changed files with 29 additions and 6 deletions

View File

@@ -58,7 +58,8 @@ func (job *ManagedJob) cycle() {
if errors.Is(err, ErrNoJobId) {
job.state = nil
}
if job.state.LastSavepointDate == nil || time.Now().Add(-job.def.Spec.SavepointInterval.Duration).After(*job.state.LastSavepointDate) {
lc.Logger.Debug("savepoint interval", zap.Any("savepoint duration", job.def.Spec.SavepointInterval))
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 {
job.createSavepoint()
} else {

View File

@@ -24,3 +24,7 @@ func NewManagedJob(client *api.Client, db *buntdb.DB, def v1alpha1.FlinkJob) *Ma
job.startCycle()
return job
}
func (job *ManagedJob) Update(def v1alpha1.FlinkJob) {
job.def = def
}

View File

@@ -13,6 +13,7 @@ func (job ManagedJob) createSavepoint() error {
lc.Logger.Debug("[managed-job] [savepoint] no job id")
return ErrNoJobId
}
lc.Logger.Info("[managed-job] [savepoint] creating savepoint", zap.String("interval", job.def.Spec.SavepointInterval.String()))
resp, err := job.client.SavePoints(*job.state.JobId, "/flink-data/savepoints-2/", false)
if err != nil {
lc.Logger.Error("[managed-job] [savepoint] error in creating savepoint", zap.Error(err))