diff --git a/make/migrations/postgresql/0120_2.9.0_schema.up.sql b/make/migrations/postgresql/0120_2.9.0_schema.up.sql index 16f6b7b71..f4424856d 100644 --- a/make/migrations/postgresql/0120_2.9.0_schema.up.sql +++ b/make/migrations/postgresql/0120_2.9.0_schema.up.sql @@ -1 +1,7 @@ CREATE INDEX IF NOT EXISTS idx_task_extra_attrs_report_uuids ON task USING gin ((extra_attrs::jsonb->'report_uuids')); + +/* Set the vendor_id of IMAGE_SCAN to the artifact id instead of scanner id, which facilitates execution sweep */ +UPDATE execution SET vendor_id = (extra_attrs -> 'artifact' ->> 'id')::integer +WHERE jsonb_path_exists(extra_attrs::jsonb, '$.artifact.id') +AND vendor_id IN (SELECT id FROM scanner_registration) +AND vendor_type = 'IMAGE_SCAN'; \ No newline at end of file diff --git a/src/controller/scan/base_controller.go b/src/controller/scan/base_controller.go index 41bf571ab..2a2e94b6e 100644 --- a/src/controller/scan/base_controller.go +++ b/src/controller/scan/base_controller.go @@ -294,7 +294,7 @@ func (bc *basicController) Scan(ctx context.Context, artifact *ar.Artifact, opti "name": r.Name, }, } - executionID, err := bc.execMgr.Create(ctx, job.ImageScanJobVendorType, r.ID, task.ExecutionTriggerManual, extraAttrs) + executionID, err := bc.execMgr.Create(ctx, job.ImageScanJobVendorType, artifact.ID, task.ExecutionTriggerManual, extraAttrs) if err != nil { return err } diff --git a/src/jobservice/job/known_jobs.go b/src/jobservice/job/known_jobs.go index 0a3d13ed2..5ff43497c 100644 --- a/src/jobservice/job/known_jobs.go +++ b/src/jobservice/job/known_jobs.go @@ -49,7 +49,8 @@ const ( var ( // executionSweeperCount stores the count for execution retained executionSweeperCount = map[string]int64{ - ScanAllVendorType: 5, + ImageScanJobVendorType: 1, + ScanAllVendorType: 1, PurgeAuditVendorType: 10, ExecSweepVendorType: 10, GarbageCollectionVendorType: 50,