-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
Note
Credits to @qweeah for finding this bug.
Problem statement: Under the mode of referrers tag schema, when all referrers of a manifest are removed the referrers index is not updated if SkipReferrersGC
is toggled to true
.
Related code:
oras-go/registry/remote/repository.go
Lines 1455 to 1476 in 4a52cfd
// 3. push the updated referrers list using referrers tag schema | |
if len(updatedReferrers) > 0 { | |
newIndexDesc, newIndex, err := generateIndex(updatedReferrers) | |
if err != nil { | |
return fmt.Errorf("failed to generate referrers index for referrers tag %s: %w", referrersTag, err) | |
} | |
if err := s.push(ctx, newIndexDesc, bytes.NewReader(newIndex), referrersTag); err != nil { | |
return fmt.Errorf("failed to push referrers index tagged by %s: %w", referrersTag, err) | |
} | |
} | |
// 4. delete the dangling original referrers index | |
if !skipDelete { | |
if err := s.repo.delete(ctx, oldIndexDesc, true); err != nil { | |
return &ReferrersError{ | |
Op: opDeleteReferrersIndex, | |
Err: fmt.Errorf("failed to delete dangling referrers index %s for referrers tag %s: %w", oldIndexDesc.Digest.String(), referrersTag, err), | |
Subject: subject, | |
} | |
} | |
} | |
return nil |
If there are no referrers (i.e. len(updatedReferrers) == 0
), we should remove the referrers index if GC is enabled as the above code does.
However, when GC is disabled / skipped, we need to keep the previous index. In this case, a new index with no manifest should be generated and pushed. Note that the image-spec
allows the index to have zero manifests
.
Wwwsylvia
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working