mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
fix(retention) execution status for zero repo
Signed-off-by: Ziming Zhang <zziming@vmware.com>
This commit is contained in:
parent
18cf7ef0df
commit
a7a1149454
@ -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
|
||||
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user