-
Notifications
You must be signed in to change notification settings - Fork 77
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
Perform an O(1) check to find layers in an image #101
Perform an O(1) check to find layers in an image #101
Conversation
f01bb41
to
5acfc3d
Compare
|
||
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY="${REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY:-/tmp/registry}" \ | ||
REGISTRY_OPENSHIFT_SERVER_ADDR="${url}" \ | ||
dockerregistry images/dockerregistry/config.yml |
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.
i assume this expects a cluster to be running somewhere, how are the coordinates of the cluster being supplied to the registry?
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.
KUBECONFIG
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.
add a usage comment at the top of the file?
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.
Done
context.GetLogger(ctx).Debugf("(*blobDescriptorService).Stat: could not stat layer link %s in repository %s: %v", dgst.String(), bs.repo.Named().Name(), err) | ||
|
||
// we couldn't find the layer link |
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.
comment should elucidate the implications of not finding the layer link
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 is just a refactor of the method, i'm happy to make better comments
firstImage = name | ||
break | ||
} | ||
return logFound(&imageapiv1.Image{ |
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.
what if layers.Layers was empty?
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.
that means the image stream has no layers
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.
yeah but we shouldn't returning found in that case, right?
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.
if we don't have a layer we return on line 43 with nil, and the if block fails, and we return ErrBlobUnknown.
} | ||
var firstImage string | ||
for name := range layers.Layers { | ||
firstImage = name |
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.
we don't actually need to find the specific image that contains the blob? any image in the imagestream will do?
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.
correct
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.
If we have the list of blobs, we don't need the image object anymore, we should just return that list.
Layers(name string) (*v1.ImageStreamLayers, error) | ||
} | ||
|
||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored). |
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.
godoc is wrong
ObjectMeta: metav1.ObjectMeta{ | ||
Name: firstImage, | ||
}, | ||
DockerImageLayers: copied, |
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.
The configuration blob for v2 scheme is missed here.
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.
RememberLayersOfImage will report the error "image %s does not have metadata"
for this image. We trying to reduce amount of logs.
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.
I’m going to remove that message. This is purely a blob access check.
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 error message means that we got incomplete image and we do not have all necessary data (we do not have the digest of config blob) and can't to cache them all. For the RememberLayersOfImage
this message is truely error.
Your handmade image object is really incomplete and hacky.
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.
Then I'll split this into RememberLayers and RememberLayersOfImage.
firstImage = name | ||
break | ||
} | ||
return logFound(&imageapiv1.Image{ |
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.
Regression. The requireManaged
was ignored. It will break config.Pullthrough.Enabled
flag.
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.
I’m not sure pullthrough enabled false is something we should support. In 8 release we’ve never had a reason to trn it off. At this point, I’d probably prefer to drop the use case.
I don’t really consider the distinction between managed an unmanaged images important anymore. If a layer is available it should be served. The image it comes from is irrelevant.
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.
Specifically, for the case where we are attempting to find the layers, I think this method should be returning a set of layers that are considered valid (which is added to the cache).
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.
I still need to add the e2e test to try and access content. Will do that once we clear up the case. |
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.
I think it is not necessary to add new features, which from the start leads to hacks. I mean the creation of images that are not images. Such image do not have all information about blobs (image blobs != image layers).
This will lead to the fact that the last code can no longer process images identically. This will greatly complicate the work with images.
@@ -37,6 +38,27 @@ func (is *imageStream) HasBlob(ctx context.Context, dgst digest.Digest, requireM | |||
return found | |||
} | |||
|
|||
if layers, err := is.imageStreamGetter.layers(); err == nil { |
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.
Why do we need to fallback to the old code?
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.
For 1 release we should tolerate the cluster not having /layers or the admin not configuring permissions. We can then remove the old code path in 3.12.
5acfc3d
to
30f40a9
Compare
30f40a9
to
cb8bb2b
Compare
Updated with the latest version of the api, all feedback added to the PR. The biggest change is the signature to Unit tests added, the e2e test will be added to the origin PR. |
/retest |
looks reasonable to me |
/retest |
Bumped dependencies in #113, which I will rebase on master after that merges. |
Was accidentally dropped when moved over from image-registry
Makes it easier to read
cb8bb2b
to
237f9d4
Compare
Updated on bumps, ready for final review. Added one commit to switch us to building on go1.10 for travis. |
b4b2837
to
1bc02cd
Compare
Because this must work during a rolling update we fall back to the older path if we get an error. A future release can drop support for the fallback path (3.12+).
1bc02cd
to
82a0a6d
Compare
No comments? I'm happy to do follow ups (I need to improve the e2e tests in origin for pulling images. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bparees, smarterclayton The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Using the new imagestream/layers API, avoid making O(N) image fetches in the case where we don't have a cached association for the reference.
API in openshift/origin#19969