From 9507d0713c6ef37d27213360061bf53e9024e720 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Mon, 3 Jul 2023 14:53:43 +0200 Subject: [PATCH] fix: Don't clean up openVSXURL on installation Signed-off-by: Anatolii Bazko --- api/v2/checluster_types.go | 6 ++++++ .../checluster-defaults-cleaner_test.go | 4 ++++ .../checluster-defaults-cleanupfunc.go | 18 ++++++------------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/api/v2/checluster_types.go b/api/v2/checluster_types.go index c0d0b327d7..72f6c7f331 100644 --- a/api/v2/checluster_types.go +++ b/api/v2/checluster_types.go @@ -873,3 +873,9 @@ func (c *CheCluster) IsEmbeddedOpenVSXRegistryConfigured() bool { } return openVSXURL == "" } + +// IsCheBeingInstalled returns true if the Che version is not set in the status. +// Basically it means that the Che is being installed since the Che version is set only after the installation. +func (c *CheCluster) IsCheBeingInstalled() bool { + return c.Status.CheVersion == "" +} diff --git a/pkg/deploy/migration/checluster-defaults-cleaner_test.go b/pkg/deploy/migration/checluster-defaults-cleaner_test.go index f77d66f2bf..0c72d46f48 100644 --- a/pkg/deploy/migration/checluster-defaults-cleaner_test.go +++ b/pkg/deploy/migration/checluster-defaults-cleaner_test.go @@ -299,6 +299,7 @@ func TestCheClusterDefaultsCleanerOpenVSXURL(t *testing.T) { }, }, }, + expectedOpenVSXURL: pointer.StringPtr("https://open-vsx.org"), }, { name: "Test use embedded OpenVSXURL after upgrade", @@ -327,6 +328,9 @@ func TestCheClusterDefaultsCleanerOpenVSXURL(t *testing.T) { }, }, }, + Status: chev2.CheClusterStatus{ + CheVersion: "7.62.0", + }, }, expectedOpenVSXURL: pointer.StringPtr("https://bla-bla-bla"), }, diff --git a/pkg/deploy/migration/checluster-defaults-cleanupfunc.go b/pkg/deploy/migration/checluster-defaults-cleanupfunc.go index ae2d47cf33..f79faded45 100644 --- a/pkg/deploy/migration/checluster-defaults-cleanupfunc.go +++ b/pkg/deploy/migration/checluster-defaults-cleanupfunc.go @@ -99,8 +99,8 @@ func cleanUpDashboardHeaderMessage(ctx *chetypes.DeployContext) (bool, error) { // cleanUpPluginRegistryOpenVSXURL cleans up CheCluster CR `Spec.Components.PluginRegistry.OpenVSXURL` field: // (complies with requirements https://github.com/eclipse/che/issues/21637): -// 1. if value equals to the default one, then set it to nil -// 2. if Eclipse Che is being installed, then use the default openVSXURL +// 1. if Eclipse Che is being installed, then use the default openVSXURL +// 2. if value equals to the default one, then set it to nil // 3. if Eclipse Che is being upgraded // * if value is and Eclipse Che v7.52 or earlier, then set the default // * if value is and Eclipse Che v7.53 or later, then set it to empty string (starts embedded registry) @@ -114,6 +114,10 @@ func cleanUpPluginRegistryOpenVSXURL(ctx *chetypes.DeployContext) (bool, error) defaults.GetPluginRegistryOpenVSXURL(), // current default (can be equal to the previous one) } + if ctx.CheCluster.IsCheBeingInstalled() { + return false, nil + } + if ctx.CheCluster.Spec.Components.PluginRegistry.OpenVSXURL != nil { for _, openVSXURL := range pluginRegistryOpenVSXURL { if *ctx.CheCluster.Spec.Components.PluginRegistry.OpenVSXURL == openVSXURL { @@ -123,16 +127,6 @@ func cleanUpPluginRegistryOpenVSXURL(ctx *chetypes.DeployContext) (bool, error) } } - // Eclipse Che is being installed - if ctx.CheCluster.Status.CheVersion == "" { - if ctx.CheCluster.IsAirGapMode() { - ctx.CheCluster.Spec.Components.PluginRegistry.OpenVSXURL = pointer.StringPtr("") - return true, nil - } - - return false, nil - } - // Eclipse Che is being upgraded if ctx.CheCluster.Spec.Components.PluginRegistry.OpenVSXURL == nil { if ctx.CheCluster.IsCheFlavor() &&