@@ -28,7 +28,7 @@ const reportSuffixURL = "/report"
28
28
const dataCheckInterval = 1.0
29
29
30
30
const rpcTimeout = time .Minute * 20
31
- const expirationTime = time .Minute * 60
31
+ const expirationTime = time .Minute * 25
32
32
const pruneTime = time .Minute * 5
33
33
34
34
var workloadID Counter
@@ -243,6 +243,10 @@ func processQueue() {
243
243
func processScanTask (scanRequest ScanRequest ) {
244
244
client , err := GetControllerServiceClient (serverConfig .ControllerIP , serverConfig .ControllerPort )
245
245
if err != nil {
246
+ reportCache .Lock ()
247
+ report := reportCache .ScanReports [scanRequest .WorkloadID ]
248
+ report .Status = http .StatusInternalServerError
249
+ reportCache .Unlock ()
246
250
log .WithFields (log.Fields {"error" : err }).Error ("Error retrieving rpc client" )
247
251
return
248
252
}
@@ -267,7 +271,7 @@ func processScanTask(scanRequest ScanRequest) {
267
271
concurrentJobs .Decrement ()
268
272
269
273
reportCache .Lock ()
270
- log .WithFields (log.Fields {"workloadId" : scanRequest .WorkloadID }).Debug ("Scan sent to controller" )
274
+ log .WithFields (log.Fields {"workloadId" : scanRequest .WorkloadID , "artifact" : scanRequest . Artifact , "registry" : scanRequest . Registry }).Debug ("Scan request forwarded to controller" )
271
275
reportCache .ScanReports [scanRequest .WorkloadID ] = convertRPCReportToScanReport (result )
272
276
reportCache .Unlock ()
273
277
}
@@ -382,15 +386,19 @@ func scanResult(w http.ResponseWriter, req *http.Request) {
382
386
log .WithFields (log.Fields {"error" : err }).Error ("json encoder error" )
383
387
w .WriteHeader (http .StatusInternalServerError )
384
388
}
389
+ log .WithFields (log.Fields {"id" : id }).Debug ("Scan report sent to Harbor" )
390
+ delete (reportCache .ScanReports , id )
391
+ case http .StatusInternalServerError :
392
+ log .WithFields (log.Fields {"id" : id }).Debug ("returned http 500 for workload id" )
393
+ http .Error (w , "NV Internal Server Error" , http .StatusInternalServerError )
385
394
delete (reportCache .ScanReports , id )
386
395
default :
387
396
w .Header ().Add ("Location" , req .URL .String ())
388
397
w .WriteHeader (val .Status )
389
398
}
390
399
} else {
391
400
w .Header ().Add ("Location" , req .URL .String ())
392
- w .Header ().Add ("Refresh-After" , "60" )
393
- w .WriteHeader (302 )
401
+ w .WriteHeader (http .StatusNotFound )
394
402
}
395
403
reportCache .Unlock ()
396
404
}
0 commit comments