Skip to content

Commit

Permalink
Try remove upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Oct 11, 2023
1 parent c245174 commit 608f0a9
Showing 1 changed file with 83 additions and 84 deletions.
167 changes: 83 additions & 84 deletions test/e2e/self_hosted.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -302,89 +301,89 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
ControlPlane: clusterResources.ControlPlane,
}, input.E2EConfig.GetIntervals(specName, "wait-control-plane")...)

By("Upgrading the self-hosted Cluster")
if clusterResources.Cluster.Spec.Topology != nil {
// Cluster is using ClusterClass, upgrade via topology.
By("Upgrading the Cluster topology")
framework.UpgradeClusterTopologyAndWaitForUpgrade(ctx, framework.UpgradeClusterTopologyAndWaitForUpgradeInput{
ClusterProxy: selfHostedClusterProxy,
Cluster: clusterResources.Cluster,
ControlPlane: clusterResources.ControlPlane,
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
MachineDeployments: clusterResources.MachineDeployments,
MachinePools: clusterResources.MachinePools,
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForEtcdUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
})
} else {
// Cluster is not using ClusterClass, upgrade via individual resources.
By("Upgrading the Kubernetes control-plane")
var (
upgradeCPMachineTemplateTo *string
upgradeWorkersMachineTemplateTo *string
)

if input.E2EConfig.HasVariable(CPMachineTemplateUpgradeTo) {
upgradeCPMachineTemplateTo = pointer.String(input.E2EConfig.GetVariable(CPMachineTemplateUpgradeTo))
}

if input.E2EConfig.HasVariable(WorkersMachineTemplateUpgradeTo) {
upgradeWorkersMachineTemplateTo = pointer.String(input.E2EConfig.GetVariable(WorkersMachineTemplateUpgradeTo))
}

framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{
ClusterProxy: selfHostedClusterProxy,
Cluster: clusterResources.Cluster,
ControlPlane: clusterResources.ControlPlane,
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
UpgradeMachineTemplate: upgradeCPMachineTemplateTo,
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForEtcdUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
})

if workerMachineCount > 0 {
By("Upgrading the machine deployment")
framework.UpgradeMachineDeploymentsAndWait(ctx, framework.UpgradeMachineDeploymentsAndWaitInput{
ClusterProxy: selfHostedClusterProxy,
Cluster: clusterResources.Cluster,
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
UpgradeMachineTemplate: upgradeWorkersMachineTemplateTo,
MachineDeployments: clusterResources.MachineDeployments,
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
})
}
}

// Only attempt to upgrade MachinePools if they were provided in the template.
if len(clusterResources.MachinePools) > 0 && workerMachineCount > 0 {
By("Upgrading the machinepool instances")
framework.UpgradeMachinePoolAndWait(ctx, framework.UpgradeMachinePoolAndWaitInput{
ClusterProxy: selfHostedClusterProxy,
Cluster: clusterResources.Cluster,
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
MachinePools: clusterResources.MachinePools,
})
}

By("Waiting until nodes are ready")
workloadProxy := selfHostedClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterResources.Cluster.Name)
workloadClient := workloadProxy.GetClient()
framework.WaitForNodesReady(ctx, framework.WaitForNodesReadyInput{
Lister: workloadClient,
KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
Count: int(clusterResources.ExpectedTotalNodes()),
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
})
// By("Upgrading the self-hosted Cluster")
// if clusterResources.Cluster.Spec.Topology != nil {
// // Cluster is using ClusterClass, upgrade via topology.
// By("Upgrading the Cluster topology")
// framework.UpgradeClusterTopologyAndWaitForUpgrade(ctx, framework.UpgradeClusterTopologyAndWaitForUpgradeInput{
// ClusterProxy: selfHostedClusterProxy,
// Cluster: clusterResources.Cluster,
// ControlPlane: clusterResources.ControlPlane,
// EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
// DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
// MachineDeployments: clusterResources.MachineDeployments,
// MachinePools: clusterResources.MachinePools,
// KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
// WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
// WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// WaitForEtcdUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// })
// } else {
// // Cluster is not using ClusterClass, upgrade via individual resources.
// By("Upgrading the Kubernetes control-plane")
// var (
// upgradeCPMachineTemplateTo *string
// upgradeWorkersMachineTemplateTo *string
// )

// if input.E2EConfig.HasVariable(CPMachineTemplateUpgradeTo) {

Check failure on line 331 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)

Check failure on line 331 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// upgradeCPMachineTemplateTo = pointer.String(input.E2EConfig.GetVariable(CPMachineTemplateUpgradeTo))
// }

// if input.E2EConfig.HasVariable(WorkersMachineTemplateUpgradeTo) {

Check failure on line 335 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)

Check failure on line 335 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// upgradeWorkersMachineTemplateTo = pointer.String(input.E2EConfig.GetVariable(WorkersMachineTemplateUpgradeTo))
// }

// framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{

Check failure on line 339 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)

Check failure on line 339 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// ClusterProxy: selfHostedClusterProxy,
// Cluster: clusterResources.Cluster,
// ControlPlane: clusterResources.ControlPlane,
// EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
// DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
// KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
// UpgradeMachineTemplate: upgradeCPMachineTemplateTo,
// WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// WaitForEtcdUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
// })

// if workerMachineCount > 0 {
// By("Upgrading the machine deployment")
// framework.UpgradeMachineDeploymentsAndWait(ctx, framework.UpgradeMachineDeploymentsAndWaitInput{
// ClusterProxy: selfHostedClusterProxy,
// Cluster: clusterResources.Cluster,
// UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
// UpgradeMachineTemplate: upgradeWorkersMachineTemplateTo,
// MachineDeployments: clusterResources.MachineDeployments,
// WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
// })
// }
// }

// // Only attempt to upgrade MachinePools if they were provided in the template.

Check failure on line 366 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)

Check failure on line 366 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// if len(clusterResources.MachinePools) > 0 && workerMachineCount > 0 {
// By("Upgrading the machinepool instances")
// framework.UpgradeMachinePoolAndWait(ctx, framework.UpgradeMachinePoolAndWaitInput{
// ClusterProxy: selfHostedClusterProxy,
// Cluster: clusterResources.Cluster,
// UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
// WaitForMachinePoolToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-upgrade"),
// MachinePools: clusterResources.MachinePools,
// })
// }

// By("Waiting until nodes are ready")

Check failure on line 378 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)

Check failure on line 378 in test/e2e/self_hosted.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// workloadProxy := selfHostedClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterResources.Cluster.Name)
// workloadClient := workloadProxy.GetClient()
// framework.WaitForNodesReady(ctx, framework.WaitForNodesReadyInput{
// Lister: workloadClient,
// KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
// Count: int(clusterResources.ExpectedTotalNodes()),
// WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
// })

By("PASSED!")
})
Expand Down

0 comments on commit 608f0a9

Please sign in to comment.