mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
fix: always remove the robot after scan job finished
1. Register task status change function for the scan job triggered by scan all. 2. Always to delete the robot account for the scan job after the job is finished because the job does not retry again when it's failed. Closes #14000 Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
42559479e6
commit
59a0e321ed
@ -46,11 +46,15 @@ func init() {
|
||||
log.Fatalf("failed to register the callback for the scan all schedule, error %v", err)
|
||||
}
|
||||
|
||||
// NOTE: the vendor type of execution for the scan job trigger by the scan all is job.ImageScanAllJob
|
||||
// NOTE: the vendor type of execution for the scan job trigger by the scan all is VendorTypeScanAll
|
||||
if err := task.RegisterCheckInProcessor(VendorTypeScanAll, scanTaskCheckInProcessor); err != nil {
|
||||
log.Fatalf("failed to register the checkin processor for the scan all job, error %v", err)
|
||||
}
|
||||
|
||||
if err := task.RegisterTaskStatusChangePostFunc(VendorTypeScanAll, scanTaskStatusChange); err != nil {
|
||||
log.Fatalf("failed to register the task status change post for the scan all job, error %v", err)
|
||||
}
|
||||
|
||||
if err := task.RegisterCheckInProcessor(job.ImageScanJob, scanTaskCheckInProcessor); err != nil {
|
||||
log.Fatalf("failed to register the checkin processor for the scan job, error %v", err)
|
||||
}
|
||||
@ -76,7 +80,6 @@ func scanTaskStatusChange(ctx context.Context, taskID int64, status string) (err
|
||||
return err
|
||||
}
|
||||
|
||||
if js == job.SuccessStatus {
|
||||
robotID := getRobotID(t.ExtraAttrs)
|
||||
if robotID > 0 {
|
||||
if err := robotCtl.Delete(ctx, robotID); err != nil {
|
||||
@ -86,7 +89,6 @@ func scanTaskStatusChange(ctx context.Context, taskID int64, status string) (err
|
||||
logger.WithField("robot_id", robotID).Debug("Robot account for the scan task is removed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifactID := getArtifactID(t.ExtraAttrs)
|
||||
if artifactID > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user