Merge pull request #1557 from tonyhb/gc-logging
Utulize config log format within gc
This commit is contained in:
commit
f4b6fc8d68
2 changed files with 12 additions and 7 deletions
|
@ -17,9 +17,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func markAndSweep(storageDriver driver.StorageDriver) error {
|
func markAndSweep(ctx context.Context, storageDriver driver.StorageDriver) error {
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
// Construct a registry
|
// Construct a registry
|
||||||
registry, err := storage.NewRegistry(ctx, storageDriver)
|
registry, err := storage.NewRegistry(ctx, storageDriver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -141,7 +139,14 @@ var GCCmd = &cobra.Command{
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = markAndSweep(driver)
|
ctx := context.Background()
|
||||||
|
ctx, err = configureLogging(ctx, config)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "unable to configure logging with config: %s", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = markAndSweep(ctx, driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to garbage collect: %v", err)
|
fmt.Fprintf(os.Stderr, "failed to garbage collect: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -161,7 +161,7 @@ func TestNoDeletionNoEffect(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run GC
|
// Run GC
|
||||||
err = markAndSweep(inmemoryDriver)
|
err = markAndSweep(context.Background(), inmemoryDriver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed mark and sweep: %v", err)
|
t.Fatalf("Failed mark and sweep: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ func TestDeletionHasEffect(t *testing.T) {
|
||||||
manifests.Delete(ctx, image3.manifestDigest)
|
manifests.Delete(ctx, image3.manifestDigest)
|
||||||
|
|
||||||
// Run GC
|
// Run GC
|
||||||
err = markAndSweep(inmemoryDriver)
|
err = markAndSweep(context.Background(), inmemoryDriver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed mark and sweep: %v", err)
|
t.Fatalf("Failed mark and sweep: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ func TestOrphanBlobDeleted(t *testing.T) {
|
||||||
uploadRandomSchema2Image(t, repo)
|
uploadRandomSchema2Image(t, repo)
|
||||||
|
|
||||||
// Run GC
|
// Run GC
|
||||||
err = markAndSweep(inmemoryDriver)
|
err = markAndSweep(context.Background(), inmemoryDriver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed mark and sweep: %v", err)
|
t.Fatalf("Failed mark and sweep: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue