mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
fix: remove inline GC and schedule a background task instead (#1610)
* fix: remove inline GC and set a default value of gc interval - remove inline GC - add a default value of GC interval - run the GC periodically by default with the default value if no interval provided - generate GC tasks with a random delay(0-30s) between - add IsReady() method to scheduler.TaskGenerator interface Signed-off-by: Andreea-Lupu <andreealupu1470@yahoo.com> * ci: add test for gc with short interval Signed-off-by: Andreea-Lupu <andreealupu1470@yahoo.com> --------- Signed-off-by: Andreea-Lupu <andreealupu1470@yahoo.com>
This commit is contained in:
@@ -218,6 +218,16 @@ func TestSignatureUploadAndVerification(t *testing.T) {
|
||||
So(err, ShouldBeNil)
|
||||
So(found, ShouldBeTrue)
|
||||
|
||||
found, err = test.ReadLogFileAndSearchString(logFile.Name(),
|
||||
"finished generating tasks for updating signatures validity", 10*time.Second)
|
||||
So(err, ShouldBeNil)
|
||||
So(found, ShouldBeTrue)
|
||||
|
||||
found, err = test.ReadLogFileAndSearchString(logFile.Name(),
|
||||
"finished resetting task generator for updating signatures validity", 10*time.Second)
|
||||
So(err, ShouldBeNil)
|
||||
So(found, ShouldBeTrue)
|
||||
|
||||
resp, err = client.R().SetHeader("Content-type", "application/octet-stream").
|
||||
SetBody([]byte("wrong content")).Post(baseURL + constants.FullCosign)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
@@ -79,6 +79,10 @@ func (gen *taskGenerator) IsDone() bool {
|
||||
return gen.done
|
||||
}
|
||||
|
||||
func (gen *taskGenerator) IsReady() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (gen *taskGenerator) Reset() {
|
||||
gen.lastRepo = ""
|
||||
gen.done = false
|
||||
|
||||
@@ -108,6 +108,10 @@ func (gen *TrivyTaskGenerator) IsDone() bool {
|
||||
return status == done
|
||||
}
|
||||
|
||||
func (gen *TrivyTaskGenerator) IsReady() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (gen *TrivyTaskGenerator) Reset() {
|
||||
gen.lock.Lock()
|
||||
gen.status = pending
|
||||
|
||||
@@ -46,6 +46,7 @@ func TestScrubExtension(t *testing.T) {
|
||||
|
||||
conf.Storage.RootDirectory = dir
|
||||
conf.Storage.Dedupe = false
|
||||
conf.Storage.GC = false
|
||||
|
||||
substore := config.StorageConfig{RootDirectory: subdir}
|
||||
conf.Storage.SubPaths = map[string]config.StorageConfig{"/a": substore}
|
||||
@@ -89,6 +90,7 @@ func TestScrubExtension(t *testing.T) {
|
||||
|
||||
conf.Storage.RootDirectory = dir
|
||||
conf.Storage.Dedupe = false
|
||||
conf.Storage.GC = false
|
||||
|
||||
conf.Log.Output = logFile.Name()
|
||||
trueValue := true
|
||||
@@ -137,6 +139,7 @@ func TestScrubExtension(t *testing.T) {
|
||||
|
||||
conf.Storage.RootDirectory = dir
|
||||
conf.Storage.Dedupe = false
|
||||
conf.Storage.GC = false
|
||||
|
||||
conf.Log.Output = logFile.Name()
|
||||
trueValue := true
|
||||
|
||||
@@ -114,6 +114,10 @@ func (gen *TaskGenerator) IsDone() bool {
|
||||
return gen.done
|
||||
}
|
||||
|
||||
func (gen *TaskGenerator) IsReady() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (gen *TaskGenerator) Reset() {
|
||||
gen.lastRepo = ""
|
||||
gen.Service.ResetCatalog()
|
||||
|
||||
@@ -131,6 +131,7 @@ func makeUpstreamServer(
|
||||
}
|
||||
|
||||
srcConfig.HTTP.Port = srcPort
|
||||
srcConfig.Storage.GC = false
|
||||
|
||||
srcDir := t.TempDir()
|
||||
|
||||
@@ -1663,6 +1664,7 @@ func TestPermsDenied(t *testing.T) {
|
||||
|
||||
destDir := t.TempDir()
|
||||
|
||||
destConfig.Storage.GC = false
|
||||
destConfig.Storage.RootDirectory = destDir
|
||||
|
||||
destConfig.Extensions = &extconf.ExtensionConfig{}
|
||||
@@ -3038,6 +3040,8 @@ func TestSubPaths(t *testing.T) {
|
||||
|
||||
srcConfig.HTTP.Port = srcPort
|
||||
|
||||
srcConfig.Storage.GC = false
|
||||
|
||||
srcDir := t.TempDir()
|
||||
|
||||
subpath := "/subpath"
|
||||
@@ -4506,6 +4510,7 @@ func TestOnDemandRetryGoroutine(t *testing.T) {
|
||||
srcBaseURL := test.GetBaseURL(srcPort)
|
||||
|
||||
srcConfig.HTTP.Port = srcPort
|
||||
srcConfig.Storage.GC = false
|
||||
|
||||
srcDir := t.TempDir()
|
||||
|
||||
@@ -4712,6 +4717,7 @@ func TestOnDemandMultipleImage(t *testing.T) {
|
||||
srcBaseURL := test.GetBaseURL(srcPort)
|
||||
|
||||
srcConfig.HTTP.Port = srcPort
|
||||
srcConfig.Storage.GC = false
|
||||
|
||||
srcDir := t.TempDir()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user