Skip to content

Conversation

@sallyom
Copy link
Contributor

@sallyom sallyom commented Apr 22, 2020

When working with mirrored release payloads, a release from a mirrored registry,
mylocalregistry/ocp/release:4.5.0-0.nightly-2020-04-18-093630 mirrored from
registry.svc.ci.openshift.org/ocp/release:4.5.0-0.nightly-2020-04-18-093630 -
In both, the tags reference quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:2eb0a51....
In oc adm release extract, always try extracting from the user-given release first. If this fails, then fall back to the release image-references. In disconnected environments, currently, oc adm release extract fails when the given release is mirrored from a connected registry.

Different from mirrored, when working with a tagged release that was uploaded to another repository, such as quay.io/sallyom/release:new, since that release wasn't mirrored, the underlying images still point to the original tag. In this case, oc adm release extract --command openshift-install will try the sallyom/release image but since that image does not exist, proceed to use the underlying tagged installer image - that will succeed as long as the user has access to the original release image. Note many devs build release w/ substitutions for one or a few component images, and this is the way they sometimes push images around.

To test this PR, do something like this:

$ podman run -p 5000:5000 -d registry:2
$ oc adm release mirror --insecure=true -a ~/pull-secret --from=registry.svc.ci.openshift.org/ocp/release:4.5.0-0.nightly-2020-04-29-144201 --to localhost:5000/ocp/release
$ oc adm release --insecure=true extract --command openshift-install localhost:5000/ocp/release:4.5.0-0.nightly-2020-04-29-144201 -v=2  

you'll find the failure from master, fixed w /this PR

Scenarios i tested:

  • build new release w/ substituting some component images from a ci/nightly/whatever, then extract or info from that
  • extract from release that was mirrored from ci or nightly and is now in disconnected registry - verify this image is extracted from disconnected registry with -v=2
  • pull down a release from ci, tag it as mine, push to my quay, extract from that
  • extract or info from a ci image (no openshift-release-dev/ocp-v4.0-art-dev reference) - if you can access registry.svc.ci images this succeeds, if not, you'll get unauthorized
  • mirror a release from local file or from localregistry to remote registry

Bugs that are resolved with these changes (or the equivalent):

@openshift-ci-robot openshift-ci-robot added bugzilla/medium bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Apr 22, 2020
@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sallyom
To complete the pull request process, please assign mfojtik
You can assign the PR to them by writing /assign @mfojtik in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 22, 2020
@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

2 similar comments
@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@openshift-ci-robot
Copy link

@sallyom: An error was encountered searching for bug 1823143 on the Bugzilla server at https://bugzilla.redhat.com:

Get https://bugzilla.redhat.com/rest/bug/1823143?api_key=CENSORED: dial tcp: i/o timeout
Please contact an administrator to resolve this issue, then request a bug refresh with /bugzilla refresh.

Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@openshift-ci-robot
Copy link

@sallyom: An error was encountered searching for bug 1823143 on the Bugzilla server at https://bugzilla.redhat.com:

Get https://bugzilla.redhat.com/rest/bug/1823143?api_key=CENSORED: dial tcp: i/o timeout
Please contact an administrator to resolve this issue, then request a bug refresh with /bugzilla refresh.

Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

1 similar comment
@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 22, 2020
@sallyom
Copy link
Contributor Author

sallyom commented Apr 22, 2020

/test e2e-cmd

@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@sallyom
Copy link
Contributor Author

sallyom commented Apr 23, 2020

/retest

@sallyom
Copy link
Contributor Author

sallyom commented Apr 23, 2020

/hold

This PR uses a bump in library-go for a not-yet-merged PR: openshift/library-go#785

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 23, 2020
@sallyom
Copy link
Contributor Author

sallyom commented Apr 24, 2020

/retest

@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Replace image registry/repository during extract if mirrored registry

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.

@sallyom
Copy link
Contributor Author

sallyom commented May 1, 2020

@soltysh I've reworked this PR, moved all changes to pkg/cli/admin/release/info.go rather than release/extract_tools.go - this is more clear. ptal, thanks.
If this direction looks better, ptal here, also, so I can remove the fake bump: openshift/library-go#785 thanks for showing me that i do not need that change doh

@sallyom sallyom force-pushed the bz1819546 branch 3 times, most recently from 329df97 to d72ae52 Compare May 2, 2020 16:28
if err != nil {
errs = append(errs, err)
return true, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be outside of the loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually looking inside ParseReference invoked at the beginning of the method that one already has that invocation see

func ParseReference(ref string) (TypedImageReference, error) {
Iow. you could just check ref.Type == DestinationRegistry and drop this above code entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, i've updated. much cleaner.
userGivenImage.AsRepository() == ref.Ref.AsRepository() :) so i can drop the userGivenImage nonsense altogether

// try to verify user-passed image tag first, in case of mirrored images this will
// exist, and if so, use this instead of the release image-reference. If this doesn't
// exist, proceed with tag from release image-reference from the readReleaseImageReference above
givenTag := fmt.Sprintf("%s@%s", userGivenImage.AsRepository(), digest)
Copy link
Contributor

Choose a reason for hiding this comment

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

tag is confusing, since this is more imageID, imageDigest, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused, you're creating a new reference from user-passed registry and release's image SHA, right? And then you parse it once again in verifyImageExists. If this works you replace the tag contents, correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't understand why you can't just use the DockerImageReference returned from userGivenImage.AsRepository() invocation and set digest there. Iow.

newRef := userGivenImage.AsRepository() // this will clear both Tag and ID fields
newRef.ID = digest
if verifyImageExists(opts, newRef)...

This way verifyImageExists will work with already passed reference, so there's no need for double parsing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks! updated, now passing imagereference.DockerImageReference to verifyImageExists, and if found, tag.From.Name = newRef.String()

if err != nil {
if imagemanifest.IsImageNotFound(err) {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition is not necessary, since in both cases you just return false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kind of, but if imageNotFound, no logging (this means it's not a mirrored image) but for any other reason should log the error, this would indicate there was an error reading the mirrored image (it exists, but there is a problem). I'm fine not logging, too, but this was my reasoning.

@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Try user-given registry/repository for extract before defaulting to referenced image

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.

@sallyom sallyom force-pushed the bz1819546 branch 2 times, most recently from 09f91c9 to b2d9989 Compare May 4, 2020 17:27
@sallyom
Copy link
Contributor Author

sallyom commented May 4, 2020

/hold cancel

fake bump removed

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 4, 2020
@sallyom
Copy link
Contributor Author

sallyom commented May 4, 2020

/retest

// try to verify user-passed image first, in case of mirrored images this will
// exist, and if so, use this instead of the release image-reference. If this doesn't
// exist, proceed with release image-reference from the readReleaseImageReference above
newRef := ref.Ref.AsRepository()
Copy link
Contributor

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).

Copy link
Member

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 oc image resolvers how to process them"? That would be great, but seems like a lot of work without vendoring more of containers/image. Or does the native oc image-resolution code already support mirrors and we'd just need to feed the ICSPs in?

Copy link
Member

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.

Copy link
Contributor Author

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:

imageContentSources:
- mirrors:
  - quay.io/sallyom/release-test
  source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
- mirrors:
  - quay.io/sallyom/release-test
  source: registry.svc.ci.openshift.org/ocp/release

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.

Copy link
Contributor

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/image is responsible for that, can you point to it?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@sallyom sallyom May 15, 2020

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 extract in 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.

Copy link
Contributor

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.

Copy link
Contributor

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).

@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Try user-given registry/repository for extract before defaulting to referenced image

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.

1 similar comment
@openshift-ci-robot
Copy link

@sallyom: This pull request references Bugzilla bug 1823143, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
Details

In response to this:

Bug 1823143: Try user-given registry/repository for extract before defaulting to referenced image

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.

@sallyom sallyom changed the title Bug 1823143: Try user-given registry/repository for extract before defaulting to referenced image Bug 1823143: Try user-given registry/repository for oc adm releaese extract|info|mirror before defaulting to referenced image May 9, 2020
@sallyom sallyom changed the title Bug 1823143: Try user-given registry/repository for oc adm releaese extract|info|mirror before defaulting to referenced image Bug 1823143: Try user-given registry/repository for oc adm release extract|info|mirror before defaulting to referenced image May 15, 2020
sallyom added 3 commits May 18, 2020 15:24
… defaulting to image reference

When working with mirrored release payloads, a release from a mirrored registry,
mylocalregistry/ocp/release:4.5.0-0.nightly-2020-04-18-093630 mirrored from
registry.svc.ci.openshift.org/ocp/release:4.5.0-0.nightly-2020-04-18-093630 -
Both reference 'quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:2eb0a51...'.
When extracting from the mirrored registry, try extracting from the user-given registry/repo/name
If this fails, then try the release image-references.
In disconnected environments, currently, oc adm release extract fails.

Different from mirrored, when working with a tagged release that was uploaded to another repository, such as
`quay.io/sallyom/release:new`, since that release wasn't mirrored, the underlying images still point to the
original tag. In this case, `oc adm release extract --command openshift-install` will try the sallyom/release image
but will fail, issue an info message, and then proceed to use the underlying tagged installer image - that will succeed
as long as the user has access to the original release image.
@openshift-ci-robot
Copy link

@sallyom: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/images 396f3d7 link /test images

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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. I understand the commands that are listed here.

@sallyom
Copy link
Contributor Author

sallyom commented May 19, 2020

closing in favor of #427 , it's less ugly, but maybe still too ugly

@sallyom
Copy link
Contributor Author

sallyom commented Jun 1, 2020

Please see #439 and openshift/enhancements#334 for progress

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

Labels

bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants