From 77734ef65df945b19312beb3a7890795a3f9379b Mon Sep 17 00:00:00 2001 From: Chenyu Zhang Date: Tue, 16 Aug 2022 13:39:47 +0800 Subject: [PATCH] [cherry-pick] enhancement: add error log for create task (#17403) enhancement: add error log for create task Signed-off-by: chlins --- src/pkg/task/execution.go | 4 ++++ src/pkg/task/task.go | 1 + 2 files changed, 5 insertions(+) diff --git a/src/pkg/task/execution.go b/src/pkg/task/execution.go index 90920da25..1f4d2f8a0 100644 --- a/src/pkg/task/execution.go +++ b/src/pkg/task/execution.go @@ -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 diff --git a/src/pkg/task/task.go b/src/pkg/task/task.go index 4b82ce2cd..9e9d288d8 100644 --- a/src/pkg/task/task.go +++ b/src/pkg/task/task.go @@ -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) }