mirror of
https://github.com/distribution/distribution
synced 2024-11-12 05:45:51 +01:00
fix: ignore error of manifest tag path not found in gc (#4331)
This commit is contained in:
commit
47a9dac250
@ -73,7 +73,8 @@ func MarkAndSweep(ctx context.Context, storageDriver driver.StorageDriver, regis
|
|||||||
// which means that we need check (and delete) those references when deleting manifest
|
// which means that we need check (and delete) those references when deleting manifest
|
||||||
allTags, err := repository.Tags(ctx).All(ctx)
|
allTags, err := repository.Tags(ctx).All(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(distribution.ErrManifestUnknownRevision); !ok {
|
if _, ok := err.(distribution.ErrRepositoryUnknown); ok {
|
||||||
|
emit("manifest tags path of repository %s does not exist", repoName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("failed to retrieve tags %v", err)
|
return fmt.Errorf("failed to retrieve tags %v", err)
|
||||||
|
@ -416,6 +416,39 @@ func TestDeleteManifestIndexIfTagNotFound(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGCWithUnknownRepository(t *testing.T) {
|
||||||
|
ctx := dcontext.Background()
|
||||||
|
d := inmemory.New()
|
||||||
|
|
||||||
|
registry := createRegistry(t, d)
|
||||||
|
repo := makeRepository(t, registry, "nonexistentrepo")
|
||||||
|
image := uploadRandomSchema2Image(t, repo)
|
||||||
|
|
||||||
|
err := repo.Tags(ctx).Tag(ctx, "image", distribution.Descriptor{Digest: image.manifestDigest})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to tag descriptor: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simulate a missing _manifests/tags directory
|
||||||
|
manifestTagsPath, err := pathFor(manifestTagsPathSpec{"nonexistentrepo"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = d.Delete(ctx, manifestTagsPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = MarkAndSweep(dcontext.Background(), d, registry, GCOpts{
|
||||||
|
DryRun: false,
|
||||||
|
RemoveUntagged: true,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("got error: %v, expected nil", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGCWithMissingManifests(t *testing.T) {
|
func TestGCWithMissingManifests(t *testing.T) {
|
||||||
ctx := dcontext.Background()
|
ctx := dcontext.Background()
|
||||||
d := inmemory.New()
|
d := inmemory.New()
|
||||||
|
Loading…
Reference in New Issue
Block a user