From 8f072a528ca0cc8fe8fd68a2e38f8bfa57393302 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 13 Nov 2020 09:26:57 +0100 Subject: [PATCH] preflight: Add dispatcher file *before* creating libvirt network The dispatcher file is only triggered upon interface creation, so it must be present - at boot time - or before the crc network is created in order to get triggered and configure crc networking as expected. TODO: check if restarting NetworkManager triggers dispatcher files --- pkg/crc/preflight/preflight_linux.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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 }