mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-26 01:21:22 +01:00
address comment
This commit is contained in:
parent
eb11cda596
commit
fb07b544ab
@ -749,6 +749,7 @@ func (ra *RepositoryAPI) ScanAll() {
|
|||||||
if !utils.ScanAllMarker().Mark() {
|
if !utils.ScanAllMarker().Mark() {
|
||||||
log.Warningf("There is a scan all scheduled at: %v, the request will not be processed.", utils.ScanAllMarker().Next())
|
log.Warningf("There is a scan all scheduled at: %v, the request will not be processed.", utils.ScanAllMarker().Next())
|
||||||
ra.RenderError(http.StatusPreconditionFailed, "Unable handle frequent scan all requests")
|
ra.RenderError(http.StatusPreconditionFailed, "Unable handle frequent scan all requests")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := uiutils.ScanAllImages(); err != nil {
|
if err := uiutils.ScanAllImages(); err != nil {
|
||||||
|
@ -16,7 +16,6 @@ package clair
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/vmware/harbor/src/common/dao"
|
"github.com/vmware/harbor/src/common/dao"
|
||||||
@ -32,24 +31,7 @@ const (
|
|||||||
rescanInterval = 15 * time.Minute
|
rescanInterval = 15 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
type timer struct {
|
|
||||||
sync.Mutex
|
|
||||||
next time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns true to indicate it should reshedule the "rescan" action.
|
|
||||||
func (t *timer) needReschedule() bool {
|
|
||||||
t.Lock()
|
|
||||||
defer t.Unlock()
|
|
||||||
if time.Now().Before(t.next) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
t.next = time.Now().Add(rescanInterval)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rescanTimer = timer{}
|
|
||||||
clairClient = clair.NewClient(config.ClairEndpoint(), nil)
|
clairClient = clair.NewClient(config.ClairEndpoint(), nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user