-
Notifications
You must be signed in to change notification settings - Fork 711
[P0] Fix #3513 ([MAJOR] content digest not found)
#4062
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| Copyright The containerd Authors. | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package converter | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/containerd/containerd/v2/core/images" | ||
| "github.com/containerd/containerd/v2/core/images/converter" | ||
| ) | ||
|
|
||
| // Something seems wrong in converter.Convert. | ||
| // When dstRef != srcRef, convert will first forcefully delete dstRef, | ||
| // *asynchronously*, then create the image. | ||
| // This seems to cause a race conditions, and the deletion may kick in after the creation. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the lease is not maintained during the creation ? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No clue. My gut intuition is that this thing faceplants when the old ref is actually exactly the same image as new ref. Note that patching containerd to also use a sync delete does NOT fix the issue. 🤔 Anyhow, for me the bottom-line really is:
|
||
| // This here is to workaround the bug, by manually creating the image first, | ||
apostasie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // then converting it in place (which avoid the problematic code-path). | ||
| // See containerd upstream discussion https://github.com/containerd/containerd/pull/11628 and | ||
| // nerdctl issues: | ||
| // https://github.com/containerd/nerdctl/issues/3509#issuecomment-2398236766 | ||
| // https://github.com/containerd/nerdctl/issues/3513 | ||
| // Note this should be remove if/when containerd merges in a fix. | ||
|
|
||
| func Convert(ctx context.Context, client converter.Client, dstRef, srcRef string, opts ...converter.Opt) (*images.Image, error) { | ||
| imageService := client.ImageService() | ||
|
|
||
| img, err := imageService.Get(ctx, srcRef) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| img.Name = dstRef | ||
|
|
||
| _ = imageService.Delete(ctx, img.Name, images.SynchronousDelete()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to delete/re-create There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not seem like we do need to delete indeed (note that I am not 100% familiar with it yet). Indeed, my containerd patch does away with the delete (which is the source of the problem), and instead tries to This patch here is opting for the least amount of change, but of course happy to clean-up a bit more if we want. lmk your preference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I don't think this is the end of it (though I am convinced this patch will significantly enhance the situation). I think in a follow-up PR we should thoroughly review our codebase and:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM to unblock the situation. But in the short and medium term, I don't want to move the containerd logic to nerdctl. |
||
|
|
||
| if _, err = imageService.Create(ctx, img); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return converter.Convert(ctx, client, dstRef, dstRef, opts...) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may explain some of the "internal: not found" errrors we sometimes see when building.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this behavior is not intuitive at all. I expect that delete to be
syncby default and the async is activated by parameter, Good catch