Skip to content

Commit

Permalink
Combine pre func
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Sep 27, 2023
1 parent b3b39ba commit 0c319f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
3 changes: 2 additions & 1 deletion test/e2e/cluster_upgrade_runtimesdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func clusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() cl
Cluster: clusterResources.Cluster,
ControlPlane: clusterResources.ControlPlane,
MachineDeployments: clusterResources.MachineDeployments,
MachinePools: clusterResources.MachinePools,
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
Expand All @@ -233,7 +234,7 @@ func clusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() cl
input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"))
},
PreWaitForMachineDeploymentToBeUpgraded: func() {
PreWaitForWorkersToBeUpgraded: func() {
machineSetPreflightChecksTestHandler(ctx,
input.BootstrapClusterProxy.GetClient(),
clusterRef)
Expand Down
47 changes: 19 additions & 28 deletions test/framework/cluster_topology_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,21 @@ func GetClusterClassByName(ctx context.Context, input GetClusterClassByNameInput

// UpgradeClusterTopologyAndWaitForUpgradeInput is the input type for UpgradeClusterTopologyAndWaitForUpgrade.
type UpgradeClusterTopologyAndWaitForUpgradeInput struct {
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
ControlPlane *controlplanev1.KubeadmControlPlane
EtcdImageTag string
DNSImageTag string
MachineDeployments []*clusterv1.MachineDeployment
MachinePools []*expv1.MachinePool
KubernetesUpgradeVersion string
WaitForMachinesToBeUpgraded []interface{}
WaitForMachinePoolToBeUpgraded []interface{}
WaitForKubeProxyUpgrade []interface{}
WaitForDNSUpgrade []interface{}
WaitForEtcdUpgrade []interface{}
PreWaitForControlPlaneToBeUpgraded func()
PreWaitForMachineDeploymentToBeUpgraded func()
PreWaitForMachinePoolToBeUpgraded func()
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
ControlPlane *controlplanev1.KubeadmControlPlane
EtcdImageTag string
DNSImageTag string
MachineDeployments []*clusterv1.MachineDeployment
MachinePools []*expv1.MachinePool
KubernetesUpgradeVersion string
WaitForMachinesToBeUpgraded []interface{}
WaitForMachinePoolToBeUpgraded []interface{}
WaitForKubeProxyUpgrade []interface{}
WaitForDNSUpgrade []interface{}
WaitForEtcdUpgrade []interface{}
PreWaitForControlPlaneToBeUpgraded func()
PreWaitForWorkersToBeUpgraded func()
}

// UpgradeClusterTopologyAndWaitForUpgrade upgrades a Cluster topology and waits for it to be upgraded.
Expand Down Expand Up @@ -155,12 +154,12 @@ func UpgradeClusterTopologyAndWaitForUpgrade(ctx context.Context, input UpgradeC
}, input.WaitForEtcdUpgrade...)
}

// Once the ControlPlane is upgraded we can run PreWaitForMachineDeploymentToBeUpgraded.
// Once the ControlPlane is upgraded we can run PreWaitForWorkersToBeUpgraded.
// Note: This can e.g. be used to verify the AfterControlPlaneUpgrade lifecycle hook is executed
// and blocking correctly.
if input.PreWaitForMachineDeploymentToBeUpgraded != nil {
log.Logf("Calling PreWaitForMachineDeploymentToBeUpgraded")
input.PreWaitForMachineDeploymentToBeUpgraded()
if input.PreWaitForWorkersToBeUpgraded != nil {
log.Logf("Calling PreWaitForWorkersToBeUpgraded")
input.PreWaitForWorkersToBeUpgraded()
}

for _, deployment := range input.MachineDeployments {
Expand All @@ -177,14 +176,6 @@ func UpgradeClusterTopologyAndWaitForUpgrade(ctx context.Context, input UpgradeC
}
}

// Once the ControlPlane is upgraded we can run PreWaitForMachinePoolToBeUpgraded.
// Note: This can e.g. be used to verify the AfterControlPlaneUpgrade lifecycle hook is executed
// and blocking correctly.
if input.PreWaitForMachinePoolToBeUpgraded != nil {
log.Logf("Calling PreWaitForMachinePoolToBeUpgraded")
input.PreWaitForMachinePoolToBeUpgraded()
}

for _, pool := range input.MachinePools {
if *pool.Spec.Replicas > 0 {
log.Logf("Waiting for Kubernetes versions of machines in MachinePool %s to be upgraded to %s",
Expand Down

0 comments on commit 0c319f2

Please sign in to comment.