Skip to content

Commit

Permalink
Skip PUCM operator update for clusters <= 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tsatam committed Sep 1, 2023
1 parent aeeca86 commit 978caba
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
68 changes: 68 additions & 0 deletions pkg/cluster/adminupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 17 additions & 1 deletion pkg/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 978caba

Please sign in to comment.