#605 add

Merged
yangxzh1 merged 1 commits from openioctopus/octopus:master into master 1 year ago
  1. +7
    -3
      server/base-server/internal/service/develop/task.go
  2. +2
    -4
      server/base-server/internal/service/trainjob/task.go

+ 7
- 3
server/base-server/internal/service/develop/task.go View File

@@ -156,7 +156,11 @@ func (s *developService) startNotebookTask() {
var payEndAt int64
var payStatus api.BillingPayRecordStatus
if utils.IsCompletedState(j.Status) {
payEndAt = j.StoppedAt.Unix()
if j.StoppedAt == nil {
payEndAt = time.Now().Unix()
} else {
payEndAt = j.StoppedAt.Unix()
}
payStatus = api.BillingPayRecordStatus_BPRS_PAY_COMPLETED
} else {
payEndAt = time.Now().Unix()
@@ -224,7 +228,7 @@ func (s *developService) startNotebookTask() {

state := utils.MapPhaseToState(typeJob.JobPhase(job.Status.State.Phase))

if utils.IsCompletedState(nbJob.Status) || strings.EqualFold(nbJob.Status, state) {
if utils.IsCompletedState(nbJob.Status) {
continue
}

@@ -259,7 +263,7 @@ func (s *developService) startNotebookTask() {
NotebookId: nb.Id,
}

if strings.EqualFold(state, constant.RUNNING) {
if strings.EqualFold(state, constant.RUNNING) && strings.EqualFold(nbJob.Status, constant.PENDING) {
nbJobUp.StartedAt = &now
record.Type = commapi.NotebookEventRecordType_RUN
} else if utils.IsCompletedState(state) {


+ 2
- 4
server/base-server/internal/service/trainjob/task.go View File

@@ -256,10 +256,8 @@ func (s *trainJobService) trainJobUpdateStaus(ctx context.Context) {
s.log.Warn(context.TODO(), "GetTrainJob err when onJobUpdate:"+job.Name, err)
continue
}

state := utils.MapPhaseToState(typeJob.JobPhase(job.Status.State.Phase))

if utils.IsCompletedState(trainJob.Status) || strings.EqualFold(trainJob.Status, state) {
if utils.IsCompletedState(trainJob.Status) {
continue
}

@@ -269,7 +267,7 @@ func (s *trainJobService) trainJobUpdateStaus(ctx context.Context) {
}

now := time.Now()
if strings.EqualFold(state, constant.RUNNING) {
if strings.EqualFold(state, constant.RUNNING) && strings.EqualFold(trainJob.Status, constant.PENDING) {
update.StartedAt = &now
} else if utils.IsCompletedState(state) {
update.CompletedAt = &now


Loading…
Cancel
Save