|
|
|
@@ -31,6 +31,9 @@ var ( |
|
|
|
) |
|
|
|
|
|
|
|
func isAdminOrOwnerOrJobCreater(ctx *context.Context, job *models.Cloudbrain, err error) bool { |
|
|
|
if !ctx.IsSigned { |
|
|
|
return false |
|
|
|
} |
|
|
|
log.Info("is repo owner:" + strconv.FormatBool(ctx.IsUserRepoOwner())) |
|
|
|
log.Info("is user admin:" + strconv.FormatBool(ctx.IsUserSiteAdmin())) |
|
|
|
if err != nil { |
|
|
|
@@ -48,16 +51,12 @@ func CanDeleteDebugJob(ctx *context.Context, job *models.Cloudbrain) bool { |
|
|
|
if job.Status != string(models.JobStopped) && job.Status != string(models.JobFailed) && job.Status != string(models.ModelArtsStartFailed) && job.Status != string(models.ModelArtsCreateFailed) { |
|
|
|
return false |
|
|
|
} |
|
|
|
if !ctx.IsSigned { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
return isAdminOrOwnerOrJobCreater(ctx, job, nil) |
|
|
|
} |
|
|
|
|
|
|
|
func CanDeleteTrainJob(ctx *context.Context, job *models.Cloudbrain) bool { |
|
|
|
if !ctx.IsSigned { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
return isAdminOrOwnerOrJobCreater(ctx, job, nil) |
|
|
|
} |
|
|
|
|
|
|
|
@@ -74,7 +73,9 @@ func CanModifyJob(ctx *context.Context, job *models.Cloudbrain) bool { |
|
|
|
} |
|
|
|
|
|
|
|
func isAdminOrJobCreater(ctx *context.Context, job *models.Cloudbrain, err error) bool { |
|
|
|
|
|
|
|
if !ctx.IsSigned { |
|
|
|
return false |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return ctx.IsUserSiteAdmin() |
|
|
|
} else { |
|
|
|
@@ -125,7 +126,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, |
|
|
|
log.Error("no such resourceSpecId(%d)", resourceSpecId, ctx.Data["MsgID"]) |
|
|
|
return errors.New("no such resourceSpec") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
jobResult, err := CreateJob(jobName, models.CreateJobParams{ |
|
|
|
JobName: jobName, |
|
|
|
RetryCount: 1, |
|
|
|
@@ -210,8 +211,8 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, |
|
|
|
JobName: jobName, |
|
|
|
SubTaskName: SubTaskName, |
|
|
|
JobType: jobType, |
|
|
|
Type: models.TypeCloudBrainOne, |
|
|
|
Uuid: uuid, |
|
|
|
Type: models.TypeCloudBrainOne, |
|
|
|
Uuid: uuid, |
|
|
|
}) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|