Skip to content

bugfix: if used cache, when delete a repository, should clear the cache, otherwise, can not push this repository again. - #3323

Closed
dk-lockdown wants to merge 1 commit into
distribution:mainfrom
dk-lockdown:bugfix_3322
Closed

dk-lockdown wants to merge 1 commit into
distribution:mainfrom
dk-lockdown:bugfix_3322

Conversation

@dk-lockdown

@dk-lockdown dk-lockdown commented Jan 5, 2021 •

Copy link
Copy Markdown

ref: #3322

Signed-off-by: 刘晓敏 [email protected]

Base automatically changed from master to main January 27, 2021 15:51
@milosgajdos

Copy link
Copy Markdown
Member

@dk-lockdown thanks for the PR. Can you please add DCO signature as per contribution guidelines

@dk-lockdown

Copy link
Copy Markdown
Author

@dk-lockdown thanks for the PR. Can you please add DCO signature as per contribution guidelines

signed

@dk-lockdown

Copy link
Copy Markdown
Author

@dmcgowan @stevvooe can you help me review this pr? thanks.

@dk-lockdown

Copy link
Copy Markdown
Author

@wy65701436 can you help me review this pr? thanks.

@abinch

abinch commented Aug 16, 2021

Copy link
Copy Markdown

Hi @dk-lockdown ,
I have tried with this commit changes, but the deleted repository still can't be pushed successful after GC, because of the blob cache.
This commit just clear the manifest cache after we sent a delete request, and then GC will remove the blobs without clear cache.
So that you can see you pushed the deleted repository successful after GC, but the registry will tell you "Layer already exists",
but it is just the cache, the registry didn't have these blobs.

Thanks.

@dk-lockdown

Copy link
Copy Markdown
Author

Hi @dk-lockdown ,
I have tried with this commit changes, but the deleted repository still can't be pushed successful after GC, because of the blob cache.
This commit just clear the manifest cache after we sent a delete request, and then GC will remove the blobs without clear cache.
So that you can see you pushed the deleted repository successful after GC, but the registry will tell you "Layer already exists",
but it is just the cache, the registry didn't have these blobs.

Thanks.

this problem solved,clear the cache when gc.

@abinch

abinch commented Sep 13, 2021

Copy link
Copy Markdown

Hi @dk-lockdown ,
I have tried with this commit changes, but the deleted repository still can't be pushed successful after GC, because of the blob cache.
This commit just clear the manifest cache after we sent a delete request, and then GC will remove the blobs without clear cache.
So that you can see you pushed the deleted repository successful after GC, but the registry will tell you "Layer already exists",
but it is just the cache, the registry didn't have these blobs.
Thanks.

this problem solved,clear the cache when gc.

The trouble is distribution have two caches, one is global cache, one is repository scope cache.
In this clear cache commit 47f696d, it only clear the global cache, and the repository scope cache still exists.

@milosgajdos

Copy link
Copy Markdown
Member

Do you want to rebase @dk-lockdown

@dk-lockdown
dk-lockdown force-pushed the bugfix_3322 branch 2 times, most recently from 4b3feb0 to 3b250a1 Compare December 25, 2023 03:06
@dk-lockdown

Copy link
Copy Markdown
Author

Do you want to rebase @dk-lockdown

rebased!

@dk-lockdown
dk-lockdown force-pushed the bugfix_3322 branch 2 times, most recently from e6dc63b to 0b3ffb2 Compare December 25, 2023 08:19
Signed-off-by: scott lewis <[email protected]>
@dk-lockdown

Copy link
Copy Markdown
Author

@milosgajdos this pr need a review

@Jamstah Jamstah left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing missing from this PR is a test case.

Also, as the garbage collection runs in a separate process, I'm not sure this will actually clear an in-memory cache successfully. I expect it could clear a redis cache.

Overall, garbage collection is designed to be run while the registry is in readonly or stopped. To switch to read only (and back) means a restart of the registry process. This means for an in-memory cache, if the registry is being administered correctly, it would be cleared after GC anyway.

This PR should also update the documentation, perhaps both the garbage collection page and the caching configuration option, to explain what the registry administrator needs to know.

return err
}

// See https://github.com/docker/distribution/issues/3322 to get more detail

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should explain the code. It can also link to a work item if you like, but the explanation should be in here.

@milosgajdos

Copy link
Copy Markdown
Member

Ping @dk-lockdown

return err
}

// See https://github.com/docker/distribution/issues/3322 to get more detail

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache can be currently cleared in cachedBlobStatter.Clear(). Maybe we should have used cachedBlobStatter in the first place?


dcontext.GetLogger(v.ctx).Infof("Deleting blob: %s", blobPath)

if v.blobDescriptorCacheProvider != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really a responsibility of GC to clear cache? I think it should already be cleared at this point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants