-
Notifications
You must be signed in to change notification settings - Fork 250
registry client: Add alternative sources methods to gather sources from ImageContentSourcePolicies #939
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
Conversation
|
/assign @dmage |
dmage
left a comment
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.
No, RepositoryList cannot exist.
To create an instance of distribution.Repository, the client sends an HTTP request to the /v2/ endpoint. If the first mirror is available and has all necessary images, the client shouldn't try to access other mirrors nor the original repository. It means distribution.Repository for the second mirror shouldn't be created until the client has checked the first mirror.
On disconnected clusters firewall can drop requests to external registries, i.e. attempt to connect to an external registry can take few minutes. So this extra action may be very time consuming.
1bc35ad to
4c38c9d
Compare
b8e5e9e to
cae89d2
Compare
1c57118 to
c343a9c
Compare
|
/retest |
c343a9c to
9d13369
Compare
|
Some high level comments:
This is not desirable - it needs to be part of library-go and the general client implementation because the behavior of ICSP is general to all OpenShift clusters, and ICSP is useful to both OpenShift specific commands (oc adm release) and generic registry commands (oc image), and in general no oc command really cares about the details or should have to care. Oleg raised the point about explicit request to use cluster ICSP vs implicit - and that's a good distinction to make. |
a3bac30 to
43a99f6
Compare
43a99f6 to
f3ae645
Compare
f3ae645 to
043d5bf
Compare
soltysh
left a comment
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.
Also seem my comments in openshift/oc#439
043d5bf to
84548ee
Compare
|
|
||
| alternates []reference.DockerImageReference | ||
| icspFile string | ||
| icspClient operatorv1alpha1client.ImageContentSourcePolicyInterface |
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 should be in a separate package as discussed before
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.
cleaned up commits & cherry-picks
pkg/image/registryclient/client.go
Outdated
| "github.com/docker/distribution/registry/client/auth/challenge" | ||
| "github.com/docker/distribution/registry/client/transport" | ||
| "github.com/opencontainers/go-digest" | ||
| imagereference "github.com/openshift/library-go/pkg/image/reference" |
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 commit merged already - surprised it still shows up 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.
i cleaned up the commits & cherry-picks, it's no longer there
b436f08 to
0e622f2
Compare
|
@smarterclayton the small modifications from your commits are in 0e622f2 , otherwise I picked yours and updated the commit msgs |
0e622f2 to
4acafb6
Compare
|
@ricardomaraschini can you please run with this PR to detect issues? Thank you, reach out on slack if needed. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sallyom, soltysh The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
I'm fine with this approach because I can make it work to solve the |
| // is true, HTTP connections are allowed and HTTPS certificate verification errors will be ignored. The returned | ||
| // Repository instance is threadsafe but the ManifestService, TagService, or BlobService are not. Note - the caller | ||
| // is responsible for providing a valid registry url for docker.io - use RepositoryForRef() to avoid that. | ||
| func (c *Context) Repository(ctx context.Context, registry *url.URL, repoName string, insecure bool) (RepositoryWithLocation, error) { |
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 change made *Context to stop implementing RepositoryRetriever interface. Was that expected?
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.
Are you currently using that interface? I'm wondering if anybody uses it. I can update the interface though.
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.
Yes, image registry repository leverages this interface in a few places.
|
@ricardomaraschini I was able to add back to |
|
@smarterclayton @ricardomaraschini I have the ICSP stuff working w/ the mirrored_client now- using the *WithLocation fns, I'll push to the oc PR so you can check it out I have cleanup w/ that PR but it's working |
I have managed to make it work this morning. The problem now (for the image registry) is the one related to the interface I mentioned here. Other problem I can solve later on is the fact that |
Implements the core of the discussion around supporting multiple sources of input. Each wrapped method in the mirroredRepository structure that needs to check alternates (methods that invoke digest lookups) will use that structure. Methods that cannot be retried will use the first alternative that has a working client (such as ServeBlob). Methods that must always use the source (mutable calls or those that don't deal with a digest) will only look at the original source, although the logic is structured so we can use data about these requests in the future. The strategy is clarified to call either FirstRequest and OnFailure, or just FirstRequest. Each repository will make a single call to the strategy, and it's up to the strategy to include the original source when invoking FirstRequest.
Right, preferring the original allows I updated the Repository method in the RepositoryRetriever interface, ptal. |
4acafb6 to
3defb0b
Compare
We can do that in another PR for sure. As long as the interface has been updated I am OK with it :-) |
|
Could we get this in? I have dependent work waiting to be done in openshift/image-registry#267 |
| @@ -0,0 +1,159 @@ | |||
| package strategy | |||
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.
discussed with maciej:
- move to oc (logic isn't generic to all callers and is more structured towards the "run once" behavior of oc, whereas controllers + registry are more informer driven)
- needs to be "lookup once and cache" to match the general behavior of oc (at the time you invoke oc any assumptions are in place)
- would like a unit test that verifies only one load is done of either file or client
| @@ -1,8 +1,9 @@ | |||
| package registryclient | |||
|
|
|||
| import ( | |||
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.
More extensive integration / unit style testing should happen in oc, which also helps us test the standard shared code. Mock testing and some basic integration testing can happen here, but oc will need to test the strategy coupled to the caller code.
Longer term there should probably a shim / stub / helper http serve function that makes it easier to stub out faking returning images (the hard bits) and inject errors and http status code. Can be longer term.
|
Replaced with #1084 |
|
@soltysh: Closed this PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Allow for multiple image source options when retrieving repository (from icsp, from mirrored)
There may be multiple image source options (from icsp, mirrored) rather than a single image source.
This PR adds registry client Context interface and methods to gather ICSP sources for a given Context.
/cc @smarterclayton
/cc @soltysh
fake bump here: openshift/oc#439