crc-org / crc

CRC is a tool to help you run containers. It manages a local OpenShift 4.x cluster, Microshift or a Podman VM optimized for testing and development purposes
https://crc.dev
Apache License 2.0
1.26k stars 238 forks source link

[BUG] No bundle type check during `crc setup` #3615

Closed cfergeau closed 2 weeks ago

cfergeau commented 1 year ago

General information

Steps to reproduce

  1. crc config set preset openshift
  2. crc setup --bundle ~/crc_podman_vfkit_4.4.2_amd64.crcbundle
    Your system is correctly setup for using CRC. Use 'crc start' to start the instance
  3. crc start --bundle ~/crc_podman_vfkit_4.4.2_amd64.crcbundle
    Preset openshift is used but bundle is provided for podman preset

Expected

crc setup detects the bundle mismatch

Actual

crc setup is successful, and tells me to run crc start

gbraad commented 1 year ago

The execution of crc setup should fail with an error message that the bundle does not match the configured preset type.

jsliacan commented 1 year ago

There's that warning:

$ crc config set preset microshift
Changes to configuration property 'preset' are only applied when the CRC instance is created.
If you already have a running CRC instance with different preset, then for this configuration change to take effect, delete the CRC instance with 'crc delete', setup it with `crc setup` and start it with 'crc start'.

$ crc setup -b ~/Downloads/crc_libvirt_4.12.9_amd64.crcbundle 
WARN Using crc_libvirt_4.12.9_amd64.crcbundle bundle, but crc_microshift_libvirt_4.12.9_amd64.crcbundle is expected for this release
.
.
.

I'm not suggesting that it's good as it is :), but for comparison crc start is successful even if some operators aren't running yet (exit code 0).

redbeam commented 2 months ago

Should the warning also be displayed together with the reason of failure? It would look like this:

$ crc setup --bundle crc_microshift_libvirt_4.16.7_amd64.crcbundle 
WARN Using crc_microshift_libvirt_4.16.7_amd64.crcbundle bundle, but crc_libvirt_4.16.7_amd64.crcbundle is expected for this release 
FATA Preset openshift is used but bundle is provided for microshift preset

The warning is displayed by this function: https://github.com/crc-org/crc/blob/e6495fe7492eb0464bfb33c55be104272cd16547/pkg/crc/validation/validation.go#L105-L118

which I assume is meant for cases when the user supplies their custom bundles.

praveenkumar commented 2 months ago

Warning for custom bundle is non-fatal and we carry on but I think in case of different preset it should be fatal and we should error out.

redbeam commented 2 weeks ago

Merged