[cherry-pick] enhancement: add error log for create task (#17403)

enhancement: add error log for create task

Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
Chenyu Zhang 2022-08-16 13:39:47 +08:00 committed by GitHub
parent d21b88eee4
commit 77734ef65d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -197,6 +197,8 @@ func (e *executionManager) sweep(ctx context.Context, vendorType string, vendorI
if !job.Status(execution.Status).Final() {
continue
}
log.Debugf("delete execution %d by sweeper", execution.ID)
if err = e.Delete(ctx, execution.ID); err != nil {
// the execution may be deleted by the other sweep operation, ignore the not found error
if errors.IsNotFoundErr(err) {
@ -352,6 +354,8 @@ func (e *executionManager) Delete(ctx context.Context, id int64) error {
return errors.New(nil).WithCode(errors.PreconditionCode).
WithMessage("the execution %d has tasks that aren't in final status, stop the tasks first", id)
}
log.Debugf("delete task %d as execution %d has been deleted", task.ID, task.ExecutionID)
if err = e.taskDAO.Delete(ctx, task.ID); err != nil {
// the tasks may be deleted by the other execution deletion operation in the same time(e.g. execution sweeper),
// ignore the not found error for the tasks

View File

@ -95,6 +95,7 @@ func (m *manager) Create(ctx context.Context, executionID int64, jb *Job, extraA
jobID, err := m.submitJob(ctx, id, jb)
if err != nil {
// failed to submit job to jobservice, delete the task record
log.Errorf("delete task %d from db due to failed to submit job %v, error: %v", id, jb.Name, err)
if err := m.dao.Delete(ctx, id); err != nil {
log.Errorf("failed to delete the task %d: %v", id, err)
}