crc icon indicating copy to clipboard operation
crc copied to clipboard

Make `-b/--bundle` argument quay-image aware

Open praveenkumar opened this issue 3 years ago • 8 comments

Till now we only had bundles on mirror which we can able to download and run it with -b but with quay integration it become tedious to consume those image as bundle so we should make -b aware of using quay image.

praveenkumar avatar Jul 27 '22 15:07 praveenkumar

you mean FQDN-aware... or perhaps even URL-aware?

gbraad avatar Aug 18 '22 10:08 gbraad

Right now -b option with different bundle (not part of Makefile bundle version) only works with dev cycle not with release bits. I think we want same for quay bundle images also. Once we start shipping the OCP bits with quay then some user/org can mirror those images to local registry (like they can store the bundle to local file server) and ask developer to use that local registry to fetch the bundle. For bundle as file it was easy to match what is present on disk and take required action (like if developer uses crc setup -b <bundle_file> then we match the <bundle_file> == <bundle_which_we_did_release>) . In case of container image we need to first fetch the image metadata and extract what version of bundle it contain and then check if that version of bundle is already part of cache directory before pulling the complete image. To make it work we first need to add LABEL to our bundle images which can provide us that detail (need issue on snc side).

We do need to put document around how to mirror the bundle container image from one registry to another and consume that one.

snc side issue: https://github.com/code-ready/snc/issues/567

praveenkumar avatar Aug 19 '22 10:08 praveenkumar

you mean FQDN-aware... or perhaps even URL-aware?

@gbraad as of now image url which taken by image package is something like \\<registry>/<user>/<image_name>:tag => \\quay.io/crcont/podman-bundle:2.7.1

  • https://github.com/code-ready/crc/blob/main/pkg/crc/image/image.go#L30

praveenkumar avatar Aug 19 '22 10:08 praveenkumar

We could also mandate that the tag has to be the bundle version. \\quay.io/crcont/podman-bundle:4.1.1, might be simpler? Can this be a real uri rather than starting with \\? docker:// for example which is what you use with skopeo. (and 2.7.1 really should be changed tocrc-2.7.1 sooner rather than later ;)

cfergeau avatar Aug 19 '22 10:08 cfergeau

you mean FQDN-aware... or perhaps even URL-aware?

Yup, supporting both --bundle docker://.... and --bundle https://.... would be nice

cfergeau avatar Aug 24 '22 07:08 cfergeau

Yup, supporting both --bundle docker://.... and --bundle https://.... would be nice

@cfergeau we need to parse it ourself then because https://github.com/code-ready/crc/blob/main/pkg/crc/image/image.go#L30 is what supported by https://github.com/code-ready/crc/blob/main/pkg/crc/image/image.go#L30, otherwise we need to use https://github.com/containers/image/blob/main/transports/alltransports/alltransports.go#L26-L37 one which first parse the given image and provide source. Also as per man containers-transports https:// is not the supported transport so I should go with docker://.

praveenkumar avatar Aug 24 '22 07:08 praveenkumar

I meant --bundle https://developers.redhat.com/content-gateway/file/pub/openshift-v4/clients/crc/bundles/openshift/4.10.9/crc_libvirt_4.10.9_amd64.crcbundle

cfergeau avatar Aug 24 '22 07:08 cfergeau

After today meeting I think I should be clear here that I am making assumption that user is not going to change the bundle name either on disk, registry-mirror or http location because one of existing logic we have to validate the bundle is using the bundle name to make sure to provide a warning the user and also will put a check for preset and bundle so if user use different preset with different bundle we fail during the validation itself instead download and extract.

Also the logic I am working from quay and http is to get the bundleName from the URI itself to make sure same bundle is already extracted and available or we need to download/pull and then extract.

func GetBundleNameFromBundlePath(preset crcpreset.Preset, bundlePath string) string {
	switch {
	case strings.HasPrefix(bundlePath, "http://"), strings.HasPrefix(bundlePath, "https://"):
		return filepath.Base(bundlePath)
	case strings.HasPrefix(bundlePath, "docker://"):
		tag := strings.Split(bundlePath, ":")[1]
		bundles := defaultBundleForOs(preset, tag)
		return bundles[runtime.GOOS]
	default:
		return filepath.Base(bundlePath)
	}
}

praveenkumar avatar Aug 25 '22 10:08 praveenkumar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 29 '22 06:10 stale[bot]

This is implemented, we'll open follow-up issues if needed to refine the behaviour.

cfergeau avatar Feb 14 '23 11:02 cfergeau