mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-19 05:11:30 +01:00
Merge pull request #14028 from heww/fix-issue-14000
fix: always remove the robot after scan job finished
This commit is contained in:
commit
cccfa40526
@ -46,11 +46,15 @@ func init() {
|
|||||||
log.Fatalf("failed to register the callback for the scan all schedule, error %v", err)
|
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 {
|
if err := task.RegisterCheckInProcessor(VendorTypeScanAll, scanTaskCheckInProcessor); err != nil {
|
||||||
log.Fatalf("failed to register the checkin processor for the scan all job, error %v", err)
|
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 {
|
if err := task.RegisterCheckInProcessor(job.ImageScanJob, scanTaskCheckInProcessor); err != nil {
|
||||||
log.Fatalf("failed to register the checkin processor for the scan job, error %v", err)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if js == job.SuccessStatus {
|
|
||||||
robotID := getRobotID(t.ExtraAttrs)
|
robotID := getRobotID(t.ExtraAttrs)
|
||||||
if robotID > 0 {
|
if robotID > 0 {
|
||||||
if err := robotCtl.Delete(ctx, robotID); err != nil {
|
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")
|
logger.WithField("robot_id", robotID).Debug("Robot account for the scan task is removed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
artifactID := getArtifactID(t.ExtraAttrs)
|
artifactID := getArtifactID(t.ExtraAttrs)
|
||||||
if artifactID > 0 {
|
if artifactID > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user