diff --git a/src/ui/api/repository.go b/src/ui/api/repository.go index d6e73df83..f9fd0c3a1 100644 --- a/src/ui/api/repository.go +++ b/src/ui/api/repository.go @@ -749,6 +749,7 @@ func (ra *RepositoryAPI) ScanAll() { if !utils.ScanAllMarker().Mark() { 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") + return } if err := uiutils.ScanAllImages(); err != nil { diff --git a/src/ui/service/notifications/clair/handler.go b/src/ui/service/notifications/clair/handler.go index 59d1c5ed5..6f5053a02 100644 --- a/src/ui/service/notifications/clair/handler.go +++ b/src/ui/service/notifications/clair/handler.go @@ -16,7 +16,6 @@ package clair import ( "encoding/json" - "sync" "time" "github.com/vmware/harbor/src/common/dao" @@ -32,24 +31,7 @@ const ( 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 ( - rescanTimer = timer{} clairClient = clair.NewClient(config.ClairEndpoint(), nil) )