mirror of
https://github.com/goharbor/harbor
synced 2025-04-21 19:09:51 +00:00
Return 409 when there is a scan all job running (#6460)
* Return 409 when user trigger another "scan all" This commit fixes #6418, that when multiple "scan all" jobs are triggered, the API should not return 500. Signed-off-by: Daniel Jiang <jiangd@vmware.com> * Update swagger to add 409 to scanAll API Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
parent
11f0e10d36
commit
29d5b5da72
@ -1342,6 +1342,8 @@ paths:
|
|||||||
description: User needs to login or call the API with correct credentials.
|
description: User needs to login or call the API with correct credentials.
|
||||||
'403':
|
'403':
|
||||||
description: User doesn't have permission to perform the action.
|
description: User doesn't have permission to perform the action.
|
||||||
|
'409':
|
||||||
|
description: There is a "scanall" job in progress, so the request cannot be served.
|
||||||
'415':
|
'415':
|
||||||
$ref: '#/responses/UnsupportedMediaType'
|
$ref: '#/responses/UnsupportedMediaType'
|
||||||
'500':
|
'500':
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/docker/distribution/manifest/schema2"
|
"github.com/docker/distribution/manifest/schema2"
|
||||||
"github.com/goharbor/harbor/src/common"
|
"github.com/goharbor/harbor/src/common"
|
||||||
"github.com/goharbor/harbor/src/common/dao"
|
"github.com/goharbor/harbor/src/common/dao"
|
||||||
|
commonhttp "github.com/goharbor/harbor/src/common/http"
|
||||||
"github.com/goharbor/harbor/src/common/models"
|
"github.com/goharbor/harbor/src/common/models"
|
||||||
"github.com/goharbor/harbor/src/common/utils"
|
"github.com/goharbor/harbor/src/common/utils"
|
||||||
"github.com/goharbor/harbor/src/common/utils/clair"
|
"github.com/goharbor/harbor/src/common/utils/clair"
|
||||||
@ -1014,6 +1015,10 @@ func (ra *RepositoryAPI) ScanAll() {
|
|||||||
}
|
}
|
||||||
if err := coreutils.ScanAllImages(); err != nil {
|
if err := coreutils.ScanAllImages(); err != nil {
|
||||||
log.Errorf("Failed triggering scan all images, error: %v", err)
|
log.Errorf("Failed triggering scan all images, error: %v", err)
|
||||||
|
if httpErr, ok := err.(*commonhttp.Error); ok && httpErr.Code == http.StatusConflict {
|
||||||
|
ra.HandleConflict("Conflict when triggering scan all images, please try again later.")
|
||||||
|
return
|
||||||
|
}
|
||||||
ra.HandleInternalServerError(fmt.Sprintf("Error: %v", err))
|
ra.HandleInternalServerError(fmt.Sprintf("Error: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user