Skip to content

Referrers tag index is not updated when all referrers are removed and GC is skipped #592

@shizhMSFT

Description

@shizhMSFT

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:

// 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions