From 978cabadc0c506ea4a453a969eb6a65177d565f5 Mon Sep 17 00:00:00 2001 From: Tanmay Satam Date: Fri, 1 Sep 2023 15:43:04 -0400 Subject: [PATCH] Skip PUCM operator update for clusters <= 4.6 --- pkg/cluster/adminupdate_test.go | 68 +++++++++++++++++++++++++++++++++ pkg/cluster/install.go | 18 ++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/adminupdate_test.go b/pkg/cluster/adminupdate_test.go index 557f23bcdae..1dd80ffcda1 100644 --- a/pkg/cluster/adminupdate_test.go +++ b/pkg/cluster/adminupdate_test.go @@ -22,6 +22,11 @@ func TestAdminUpdateSteps(t *testing.T) { Key: strings.ToLower(key), OpenShiftCluster: &api.OpenShiftCluster{ ID: key, + Properties: api.OpenShiftClusterProperties{ + ClusterProfile: api.ClusterProfile{ + Version: "4.10.0", + }, + }, }, } } @@ -53,6 +58,26 @@ func TestAdminUpdateSteps(t *testing.T) { "[Condition ensureAROOperatorRunningDesiredVersion-fm, timeout 5m0s]", }, }, + { + name: "ARO Operator Update on <= 4.6 cluster does not update operator", + fixture: func() (*api.OpenShiftClusterDocument, bool) { + doc := baseClusterDoc() + doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateAdminUpdating + doc.OpenShiftCluster.Properties.MaintenanceTask = api.MaintenanceTaskOperator + doc.OpenShiftCluster.Properties.ClusterProfile.Version = "4.6.62" + return doc, true + }, + shouldRunSteps: []string{ + "[Action initializeKubernetesClients-fm]", + "[Action ensureBillingRecord-fm]", + "[Action ensureDefaults-fm]", + "[AuthorizationRetryingAction fixupClusterSPObjectID-fm]", + "[Action fixInfraID-fm]", + "[Action startVMs-fm]", + "[Condition apiServersReady-fm, timeout 30m0s]", + "[Action initializeOperatorDeployer-fm]", + }, + }, { name: "Everything update", fixture: func() (*api.OpenShiftClusterDocument, bool) { @@ -98,6 +123,49 @@ func TestAdminUpdateSteps(t *testing.T) { "[Action updateProvisionedBy-fm]", }, }, + { + name: "Everything update on <= 4.6 cluster does not update operator", + fixture: func() (*api.OpenShiftClusterDocument, bool) { + doc := baseClusterDoc() + doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateAdminUpdating + doc.OpenShiftCluster.Properties.MaintenanceTask = api.MaintenanceTaskEverything + doc.OpenShiftCluster.Properties.ClusterProfile.Version = "4.6.62" + return doc, true + }, + shouldRunSteps: []string{ + "[Action initializeKubernetesClients-fm]", + "[Action ensureBillingRecord-fm]", + "[Action ensureDefaults-fm]", + "[AuthorizationRetryingAction fixupClusterSPObjectID-fm]", + "[Action fixInfraID-fm]", + "[Action ensureResourceGroup-fm]", + "[Action createOrUpdateDenyAssignment-fm]", + "[Action ensureServiceEndpoints-fm]", + "[Action populateRegistryStorageAccountName-fm]", + "[Action migrateStorageAccounts-fm]", + "[Action fixSSH-fm]", + "[Action populateDatabaseIntIP-fm]", + "[Action startVMs-fm]", + "[Condition apiServersReady-fm, timeout 30m0s]", + "[Action fixSREKubeconfig-fm]", + "[Action fixUserAdminKubeconfig-fm]", + "[Action createOrUpdateRouterIPFromCluster-fm]", + "[Action fixMCSCert-fm]", + "[Action fixMCSUserData-fm]", + "[Action ensureGatewayUpgrade-fm]", + "[Action rotateACRTokenPassword-fm]", + "[Action configureAPIServerCertificate-fm]", + "[Action configureIngressCertificate-fm]", + "[Action populateRegistryStorageAccountName-fm]", + "[Action ensureMTUSize-fm]", + "[Action initializeOperatorDeployer-fm]", + "[Action hiveCreateNamespace-fm]", + "[Action hiveEnsureResources-fm]", + "[Condition hiveClusterDeploymentReady-fm, timeout 5m0s]", + "[Action hiveResetCorrelationData-fm]", + "[Action updateProvisionedBy-fm]", + }, + }, { name: "Blank, Hive not adopting (should perform everything but Hive)", fixture: func() (*api.OpenShiftClusterDocument, bool) { diff --git a/pkg/cluster/install.go b/pkg/cluster/install.go index 5fba938bd5e..d136938ddd4 100644 --- a/pkg/cluster/install.go +++ b/pkg/cluster/install.go @@ -8,6 +8,7 @@ import ( "fmt" "time" + "github.com/coreos/go-semver/semver" configclient "github.com/openshift/client-go/config/clientset/versioned" imageregistryclient "github.com/openshift/client-go/imageregistry/clientset/versioned" machineclient "github.com/openshift/client-go/machine/clientset/versioned" @@ -28,6 +29,10 @@ import ( "github.com/Azure/ARO-RP/pkg/util/version" ) +const ( + operatorCutoffVersion = "4.7.0" // OCP versions older than this will not receive ARO operator updates +) + // AdminUpdate performs an admin update of an ARO cluster func (m *manager) AdminUpdate(ctx context.Context) error { toRun := m.adminUpdate() @@ -127,7 +132,7 @@ func (m *manager) adminUpdate() []steps.Step { } // Update the ARO Operator - if isEverything || isOperator { + if (isEverything || isOperator) && m.shouldUpdateOperator() { toRun = append(toRun, steps.Action(m.ensureAROOperator), steps.Condition(m.aroDeploymentReady, 20*time.Minute, true), @@ -156,6 +161,17 @@ func (m *manager) adminUpdate() []steps.Step { return toRun } +func (m *manager) shouldUpdateOperator() bool { + runningVersion, err := semver.NewVersion(m.doc.OpenShiftCluster.Properties.ClusterProfile.Version) + if err != nil { + return false + } + + cutoffVersion := semver.New(operatorCutoffVersion) + + return cutoffVersion.LessThan(*runningVersion) +} + func (m *manager) clusterWasCreatedByHive() bool { if m.doc.OpenShiftCluster.Properties.HiveProfile.Namespace == "" { return false