Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shizhMSFT opened this issue Sep 7, 2023 · 0 comments · Fixed by #593
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@shizhMSFT
Copy link
Contributor

shizhMSFT commented Sep 7, 2023

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.

@shizhMSFT shizhMSFT added the bug Something isn't working label Sep 7, 2023
@shizhMSFT shizhMSFT added this to the v2.4.0 milestone Sep 7, 2023
Wwwsylvia added a commit that referenced this issue Sep 12, 2023
…errersGC (#593)

Fix: #592
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Wwwsylvia added a commit to Wwwsylvia/oras-go that referenced this issue Oct 19, 2023
…errersGC (oras-project#593)

Fix: oras-project#592
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
shizhMSFT pushed a commit that referenced this issue Oct 20, 2023
…errersGC (#593)

Fix: #592
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants