From 3f3acbab739cc7017878312ec2e0a2953dfffb3d Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Fri, 9 Feb 2024 17:58:05 +0530 Subject: [PATCH] Add deprecation warning in case user are on macOS < 13 This will add deprecation warning of old macOS users since we always support latest 2 major release and 14.x and 13.x is already present. Till now we also supported 12.x but this we should stop supporting so this deprecation warning help user to prepare for it. --- packaging/darwin/Distribution.in | 7 +++++++ pkg/crc/preflight/preflight_checks_darwin.go | 12 ++++++++++++ pkg/crc/preflight/preflight_darwin.go | 12 ++++++++++++ pkg/crc/preflight/preflight_darwin_test.go | 10 +++++----- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/packaging/darwin/Distribution.in b/packaging/darwin/Distribution.in index 46d4fa766e..8e77864a25 100755 --- a/packaging/darwin/Distribution.in +++ b/packaging/darwin/Distribution.in @@ -26,6 +26,13 @@ function installCheck() { my.result.type = 'Fatal'; return false; } + + if(!(system.compareVersions(system.version.ProductVersion, '13.0.0') >= 0)) { + my.result.title = 'Deprecation warning'; + my.result.message = 'This version of macOS is going to be unsupported for Red Hat OpenShift Local, Please update to macOS 13 or newer'; + my.result.type = 'Warning'; + return true; + } return true; } diff --git a/pkg/crc/preflight/preflight_checks_darwin.go b/pkg/crc/preflight/preflight_checks_darwin.go index 55a7da36d3..e0fd3b5b6f 100644 --- a/pkg/crc/preflight/preflight_checks_darwin.go +++ b/pkg/crc/preflight/preflight_checks_darwin.go @@ -15,6 +15,7 @@ import ( "github.com/crc-org/crc/v2/pkg/crc/machine/vfkit" "github.com/crc-org/crc/v2/pkg/crc/version" crcos "github.com/crc-org/crc/v2/pkg/os" + "github.com/crc-org/crc/v2/pkg/os/darwin" "github.com/crc-org/crc/v2/pkg/os/darwin/launchd" "github.com/klauspost/cpuid/v2" "golang.org/x/sys/unix" @@ -224,3 +225,14 @@ func fixPlistFileExists(agentConfig launchd.AgentConfig) error { } return waitForDaemonRunning() } + +func deprecationNotice() error { + supports, err := darwin.AtLeast("13.0.0") + if err != nil { + return err + } + if !supports { + logging.Warnf("This version of macOS is going to be unsupported for CRC, Please update to macOS 13 or newer") + } + return nil +} diff --git a/pkg/crc/preflight/preflight_darwin.go b/pkg/crc/preflight/preflight_darwin.go index 48f6735672..b4d963d11c 100644 --- a/pkg/crc/preflight/preflight_darwin.go +++ b/pkg/crc/preflight/preflight_darwin.go @@ -10,6 +10,17 @@ import ( "github.com/crc-org/crc/v2/pkg/os/darwin/launchd" ) +// Deprecate warning for older version of mac<13.x +var deprecationWarning = Check{ + configKeySuffix: "check-mac-version", + checkDescription: "Checking if running macOS version >= 13.x", + check: deprecationNotice, + fixDescription: "This version of macOS is going to be unsupported on CRC", + flags: NoFix, + + labels: labels{Os: Darwin}, +} + // SetupHost performs the prerequisite checks and setups the host to run the cluster var vfkitPreflightChecks = []Check{ { @@ -105,6 +116,7 @@ func getAllPreflightChecks() []Check { func getChecks(_ network.Mode, bundlePath string, preset crcpreset.Preset, enableBundleQuayFallback bool) []Check { checks := []Check{} + checks = append(checks, deprecationWarning) checks = append(checks, nonWinPreflightChecks...) checks = append(checks, genericPreflightChecks(preset)...) checks = append(checks, memoryCheck(preset)) diff --git a/pkg/crc/preflight/preflight_darwin_test.go b/pkg/crc/preflight/preflight_darwin_test.go index 12c2687ac6..4a1c83bf7c 100644 --- a/pkg/crc/preflight/preflight_darwin_test.go +++ b/pkg/crc/preflight/preflight_darwin_test.go @@ -13,13 +13,13 @@ import ( func TestCountConfigurationOptions(t *testing.T) { cfg := config.New(config.NewEmptyInMemoryStorage(), config.NewEmptyInMemorySecretStorage()) RegisterSettings(cfg) - assert.Len(t, cfg.AllConfigs(), 12) + assert.Len(t, cfg.AllConfigs(), 13) } func TestCountPreflights(t *testing.T) { - assert.Len(t, getPreflightChecks(true, network.SystemNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 18) - assert.Len(t, getPreflightChecks(true, network.SystemNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 18) + assert.Len(t, getPreflightChecks(true, network.SystemNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 19) + assert.Len(t, getPreflightChecks(true, network.SystemNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 19) - assert.Len(t, getPreflightChecks(true, network.UserNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 17) - assert.Len(t, getPreflightChecks(true, network.UserNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 17) + assert.Len(t, getPreflightChecks(true, network.UserNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 18) + assert.Len(t, getPreflightChecks(true, network.UserNetworkingMode, constants.GetDefaultBundlePath(preset.OpenShift), preset.OpenShift, false), 18) }