Skip to content

Commit

Permalink
fix: Don't clean up openVSXURL on installation
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Jul 3, 2023
1 parent 770b670 commit 9507d07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 6 additions & 0 deletions api/v2/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ""
}
4 changes: 4 additions & 0 deletions pkg/deploy/migration/checluster-defaults-cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func TestCheClusterDefaultsCleanerOpenVSXURL(t *testing.T) {
},
},
},
expectedOpenVSXURL: pointer.StringPtr("https://open-vsx.org"),
},
{
name: "Test use embedded OpenVSXURL after upgrade",
Expand Down Expand Up @@ -327,6 +328,9 @@ func TestCheClusterDefaultsCleanerOpenVSXURL(t *testing.T) {
},
},
},
Status: chev2.CheClusterStatus{
CheVersion: "7.62.0",
},
},
expectedOpenVSXURL: pointer.StringPtr("https://bla-bla-bla"),
},
Expand Down
18 changes: 6 additions & 12 deletions pkg/deploy/migration/checluster-defaults-cleanupfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <not set> and Eclipse Che v7.52 or earlier, then set the default
// * if value is <not set> and Eclipse Che v7.53 or later, then set it to empty string (starts embedded registry)
Expand All @@ -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 {
Expand All @@ -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() &&
Expand Down

0 comments on commit 9507d07

Please sign in to comment.