30 lines
714 B
Go
30 lines
714 B
Go
package managed_job
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"gitea.com/logicamp/lc"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (job *ManagedJob) checkStatus() error {
|
|
if job.state.JobId == nil {
|
|
lc.Logger.Debug("[managed-job] [status] no job id")
|
|
return ErrNoJobId
|
|
}
|
|
statusResp, err := job.client.Job(*job.state.JobId)
|
|
if err != nil {
|
|
lc.Logger.Debug("[managed-job] [status] cannot fetch status", zap.Error(err))
|
|
if strings.IndexAny(err.Error(), "http status not 2xx: 404") == 0 {
|
|
job.updateState(jobState{
|
|
JobId: job.state.JobId,
|
|
Status: JobStatusNotFound,
|
|
})
|
|
}
|
|
return err
|
|
}
|
|
//lc.Logger.Debug("[managed-job] [status]", zap.Any("status-resp", statusResp))
|
|
job.SetStatus(JobStatus(statusResp.State))
|
|
return err
|
|
}
|