diff --git a/src/common/utils/timemarker.go b/src/common/utils/timemarker.go index e61b0451c..df106af18 100644 --- a/src/common/utils/timemarker.go +++ b/src/common/utils/timemarker.go @@ -15,8 +15,6 @@ package utils import ( - "os" - "strconv" "sync" "time" ) @@ -57,23 +55,6 @@ func (t *TimeMarker) Next() time.Time { return t.next } -// ScanAllMarker ... -func ScanAllMarker() *TimeMarker { - once.Do(func() { - a := os.Getenv("HARBOR_SCAN_ALL_INTERVAL") - if m, err := strconv.Atoi(a); err == nil { - scanAllMarker = &TimeMarker{ - interval: time.Duration(m) * time.Minute, - } - } else { - scanAllMarker = &TimeMarker{ - interval: 2 * time.Hour, - } - } - }) - return scanAllMarker -} - // ScanOverviewMarker ... func ScanOverviewMarker() *TimeMarker { return scanOverviewMarker diff --git a/src/common/utils/timemarker_test.go b/src/common/utils/timemarker_test.go index 203a46dc4..81722e0cc 100644 --- a/src/common/utils/timemarker_test.go +++ b/src/common/utils/timemarker_test.go @@ -16,7 +16,6 @@ package utils import ( "github.com/stretchr/testify/assert" - "os" "testing" "time" ) @@ -36,14 +35,3 @@ func TestTimeMarker(t *testing.T) { r3 := m.Check() assert.True(r3) } - -func TestScanMarkers(t *testing.T) { - assert := assert.New(t) - os.Setenv("HARBOR_SCAN_ALL_INTERVAL", "5") - sm := ScanAllMarker() - d := sm.Next().Sub(time.Now()) - assert.True(d <= 5*time.Minute) - som := ScanOverviewMarker() - d = som.Next().Sub(time.Now()) - assert.True(d <= 15*time.Second) -} diff --git a/src/core/api/repository.go b/src/core/api/repository.go index cd252cc9b..b45b84948 100644 --- a/src/core/api/repository.go +++ b/src/core/api/repository.go @@ -1012,18 +1012,11 @@ func (ra *RepositoryAPI) ScanAll() { ra.HandleForbidden(ra.SecurityCtx.GetUsername()) return } - if !utils.ScanAllMarker().Check() { - 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 := coreutils.ScanAllImages(); err != nil { log.Errorf("Failed triggering scan all images, error: %v", err) ra.HandleInternalServerError(fmt.Sprintf("Error: %v", err)) return } - utils.ScanAllMarker().Mark() ra.Ctx.ResponseWriter.WriteHeader(http.StatusAccepted) } diff --git a/src/core/api/systeminfo.go b/src/core/api/systeminfo.go index 619af3dd9..422d64f8c 100644 --- a/src/core/api/systeminfo.go +++ b/src/core/api/systeminfo.go @@ -98,7 +98,6 @@ type GeneralInfo struct { SelfRegistration bool `json:"self_registration"` HasCARoot bool `json:"has_ca_root"` HarborVersion string `json:"harbor_version"` - NextScanAll int64 `json:"next_scan_all"` ClairVulnStatus *models.ClairVulnerabilityStatus `json:"clair_vulnerability_status,omitempty"` RegistryStorageProviderName string `json:"registry_storage_provider_name"` ReadOnly bool `json:"read_only"` @@ -187,11 +186,6 @@ func (sia *SystemInfoAPI) GetGeneralInfo() { } if info.WithClair { info.ClairVulnStatus = getClairVulnStatus() - t := utils.ScanAllMarker().Next().UTC().Unix() - if t < 0 { - t = 0 - } - info.NextScanAll = t } sia.Data["json"] = info sia.ServeJSON()