feat: allow restore jobs that has not any taken save point
This commit is contained in:
parent
c066a9fd90
commit
b2d2295d07
@ -102,6 +102,10 @@ func (job *ManagedJob) Cycle() {
|
||||
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)))
|
||||
}
|
||||
|
||||
@ -14,23 +14,26 @@ import (
|
||||
|
||||
// restore the job from savepoint and jarId in managedJob
|
||||
func (job *ManagedJob) restore() error {
|
||||
var savepointPath string
|
||||
if job.def.Status.LastSavepointPath == nil {
|
||||
pkg.Logger.Error("[managed-job] [restore]", zap.Error(v1alpha1.ErrNoSavepointPath))
|
||||
return v1alpha1.ErrNoSavepointPath
|
||||
//return v1alpha1.ErrNoSavepointPath
|
||||
} else {
|
||||
savepointPath = *job.def.Status.LastSavepointPath
|
||||
}
|
||||
if job.def.Status.JarId == nil {
|
||||
err := errors.New("missing jar id")
|
||||
pkg.Logger.Error("[managed-job] [restore]", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
pkg.Logger.Info("[managed-job] [restore] restoring job", zap.String("name", job.def.GetName()), zap.String("savepointPath", *job.def.Status.LastSavepointPath))
|
||||
pkg.Logger.Info("[managed-job] [restore] restoring job", zap.String("name", job.def.GetName()), zap.String("savepointPath", savepointPath))
|
||||
var jobId *string
|
||||
for {
|
||||
runJarResp, err := job.client.RunJar(api.RunOpts{
|
||||
JarID: *job.def.Status.JarId,
|
||||
AllowNonRestoredState: true,
|
||||
EntryClass: job.def.Spec.EntryClass,
|
||||
SavepointPath: *job.def.Status.LastSavepointPath,
|
||||
SavepointPath: savepointPath,
|
||||
})
|
||||
if err != nil {
|
||||
if strings.ContainsAny(err.Error(), ".jar does not exist") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user