Skip to content

Commit

Permalink
utulize config log format within gc
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Holdstock-Brown <tony@docker.com>
  • Loading branch information
tonyhb authored and RichardScothern committed Mar 24, 2016
1 parent 04d3ca7 commit c6b8499
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions registry/garbagecollect.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import (
"github.com/spf13/cobra"
)

func markAndSweep(storageDriver driver.StorageDriver) error {
ctx := context.Background()

func markAndSweep(ctx context.Context, storageDriver driver.StorageDriver) error {
// Construct a registry
registry, err := storage.NewRegistry(ctx, storageDriver)
if err != nil {
Expand Down Expand Up @@ -141,7 +139,14 @@ var GCCmd = &cobra.Command{
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 {
fmt.Fprintf(os.Stderr, "failed to garbage collect: %v", err)
os.Exit(1)
Expand Down
6 changes: 3 additions & 3 deletions registry/garbagecollect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestNoDeletionNoEffect(t *testing.T) {
}

// Run GC
err = markAndSweep(inmemoryDriver)
err = markAndSweep(context.Background(), inmemoryDriver)
if err != nil {
t.Fatalf("Failed mark and sweep: %v", err)
}
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestDeletionHasEffect(t *testing.T) {
manifests.Delete(ctx, image3.manifestDigest)

// Run GC
err = markAndSweep(inmemoryDriver)
err = markAndSweep(context.Background(), inmemoryDriver)
if err != nil {
t.Fatalf("Failed mark and sweep: %v", err)
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func TestOrphanBlobDeleted(t *testing.T) {
uploadRandomSchema2Image(t, repo)

// Run GC
err = markAndSweep(inmemoryDriver)
err = markAndSweep(context.Background(), inmemoryDriver)
if err != nil {
t.Fatalf("Failed mark and sweep: %v", err)
}
Expand Down

0 comments on commit c6b8499

Please sign in to comment.