diff --git a/pkg/crc/preflight/preflight_linux.go b/pkg/crc/preflight/preflight_linux.go index 529823001a..246465c9c9 100644 --- a/pkg/crc/preflight/preflight_linux.go +++ b/pkg/crc/preflight/preflight_linux.go @@ -64,6 +64,14 @@ var libvirtPreflightChecks = [...]Check{ fixDescription: "Installing crc-driver-libvirt", fix: fixMachineDriverLibvirtInstalled, }, + { + cleanupDescription: "Removing the crc VM if exists", + cleanup: removeCrcVM, + flags: CleanUpOnly, + }, +} + +var libvirtNetworkPreflightChecks = [...]Check{ { configKeySuffix: "check-crc-network", checkDescription: "Checking if libvirt 'crc' network is available", @@ -80,11 +88,6 @@ var libvirtPreflightChecks = [...]Check{ fixDescription: "Starting libvirt 'crc' network", fix: fixLibvirtCrcNetworkActive, }, - { - cleanupDescription: "Removing the crc VM if exists", - cleanup: removeCrcVM, - flags: CleanUpOnly, - }, } var vsockPreflightChecks = Check{ @@ -162,8 +165,8 @@ func getPreflightChecks(_ bool, networkMode network.Mode) []Check { return getPreflightChecksForDistro(distro(), networkMode) } -func getPreflightChecksForDistro(distro *linux.OsRelease, networkMode network.Mode) []Check { - checks := commonChecks() +func getNetworkChecksForDistro(distro *linux.OsRelease, networkMode network.Mode) []Check { + var checks []Check if networkMode == network.VSockMode { return append(checks, vsockPreflightChecks) @@ -187,11 +190,14 @@ func getPreflightChecksForDistro(distro *linux.OsRelease, networkMode network.Mo return checks } -func commonChecks() []Check { +func getPreflightChecksForDistro(distro *linux.OsRelease, networkMode network.Mode) []Check { var checks []Check checks = append(checks, genericPreflightChecks[:]...) checks = append(checks, nonWinPreflightChecks[:]...) checks = append(checks, libvirtPreflightChecks[:]...) + networkChecks := getNetworkChecksForDistro(distro, networkMode) + checks = append(checks, networkChecks...) + checks = append(checks, libvirtNetworkPreflightChecks[:]...) return checks }