fix(retention) execution status for zero repo

Signed-off-by: Ziming Zhang <zziming@vmware.com>
This commit is contained in:
Ziming Zhang 2021-01-13 18:24:30 +08:00 committed by Ziming
parent 18cf7ef0df
commit a7a1149454
2 changed files with 7 additions and 1 deletions

View File

@ -230,7 +230,7 @@ func (r *defaultController) TriggerRetentionExec(ctx context.Context, policyID i
"dry_run": dryRun,
},
)
if _, err = r.launcher.Launch(ctx, p, id, dryRun); err != nil {
if num, err := r.launcher.Launch(ctx, p, id, dryRun); err != nil {
if err1 := r.execMgr.StopAndWait(ctx, id, 10*time.Second); err1 != nil {
logger.Errorf("failed to stop the retention execution %d: %v", id, err1)
}
@ -238,6 +238,11 @@ func (r *defaultController) TriggerRetentionExec(ctx context.Context, policyID i
logger.Errorf("failed to mark error for the retention execution %d: %v", id, err1)
}
return 0, err
} else if num == 0 {
// no candidates, mark the execution as done directly
if err := r.execMgr.MarkDone(ctx, id, "no resources for retention"); err != nil {
logger.Errorf("failed to mark done for the execution %d: %v", id, err)
}
}
return id, err

View File

@ -210,6 +210,7 @@ func (s *ControllerTestSuite) TestExecution() {
"dry_run": true,
},
}, nil)
execMgr.On("MarkDone", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
execMgr.On("List", mock.Anything, mock.Anything).Return([]*task.Execution{{
ID: 1,
Status: job.RunningStatus.String(),