address comment

This commit is contained in:
Tan Jiang 2017-07-10 13:53:21 +08:00
parent eb11cda596
commit fb07b544ab
2 changed files with 1 additions and 18 deletions

View File

@ -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 {

View File

@ -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)
) )