-
Notifications
You must be signed in to change notification settings - Fork 426
Bug 1823143: Try user-given registry/repository for oc adm release extract|info|mirror before defaulting to referenced image #395
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package release | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "k8s.io/klog" | ||
|
|
||
| "github.com/openshift/library-go/pkg/image/reference" | ||
| "github.com/openshift/library-go/pkg/image/registryclient" | ||
| "github.com/openshift/oc/pkg/cli/image/imagesource" | ||
| imagemanifest "github.com/openshift/oc/pkg/cli/image/manifest" | ||
| ) | ||
|
|
||
| func verifyImageExists(fromContext *registryclient.Context, fileDir string, insecure bool, include imagemanifest.FilterFunc, ref reference.DockerImageReference) bool { | ||
| from := imagesource.TypedImageReference{Type: imagesource.DestinationRegistry, Ref: ref} | ||
| ctx := context.Background() | ||
| fromOptions := &imagesource.Options{ | ||
| FileDir: fileDir, | ||
| Insecure: insecure, | ||
| RegistryContext: fromContext, | ||
| } | ||
|
|
||
| repo, err := fromOptions.Repository(ctx, from) | ||
| if err != nil { | ||
| klog.V(2).Infof("unable to connect to image repository %s: %v", from.String(), err) | ||
| return false | ||
| } | ||
| _, _, err = imagemanifest.FirstManifest(ctx, from.Ref, repo, include) | ||
| if err != nil { | ||
| if imagemanifest.IsImageNotFound(err) { | ||
| return false | ||
| } | ||
| klog.V(2).Infof("unable to read image %s: %v", from.String(), err) | ||
| return false | ||
| } | ||
| return true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Assuming that the release image and the target share the same repository is a really ugly hack. I don't think it's appropriate without the user explicitly telling us where it is (perhaps via a flag, perhaps by providing an ICSP).
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.
So is this "pull down any ICSPs from the cluster and teach the local
ocimage resolvers how to process them"? That would be great, but seems like a lot of work without vendoring more ofcontainers/image. Or does the nativeocimage-resolution code already support mirrors and we'd just need to feed the ICSPs in?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.
... and there is no guarantee that ICSPs that make sense for the cluster also make sense for wherever the user is running
oc. Would be nice if we had image-streams for every image referenced from the release image or some such, so we could pull from there without having to reach out and hit some external 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.
so ICS is printed when mirroring image like so:
so if an image is mirrored pass a flag to provide that info? i don't have details for how to use this info atm, i'll take a look.
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.
OK, that's fair and w/o that information it's ok to not to have properly working disconnected mirrors working, exactly like described in the bug. The second question is I can't seem to find which piece of
containers/imageis responsible for that, can you point to it?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.
It would be more appropriate right now to add a flag that is "--mirror-repository=foo/bar" (possibly that supports multiple flags via StringSlice) than to add magic lookup. In the future, reeading from an ICSP file or ICSP on the cluster might be reasonable. Right now, don't do magic.
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.
Adding error path when image can't be found to suggest that if this is a mirrored repository to provide that flag, and to add a paragraph to help that describes how to work with mirrored repositories, would also be required to make this clear to users.
Uh oh!
There was an error while loading. Please reload this page.
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.
but how will that solve 'I can't
oc adm release extractin disconnected environment'?As/is, the cmd does that-extracts from the mirrored repository (you don't have to pass it), and succeeds if you are connected and have the correct pull secret for that repo but fails otherwise.
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 flag would add additional search locations (like ICSP) if the first fetch fails. All locations that look at an image would support the alternates.
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.
You would be designing in (vs adding hacks) a mechanism that says "if i get an image, if i can't get it at location A, try B, C, and D by digest". That mechanism probably should be in the lowest level client (the registry fetcher) which would transparently support this for all commands (i.e. putting code into mirror is probably wrong).