Skip to content

Commit

Permalink
allow provider specific infra machine template for upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aartij17 committed Feb 8, 2022
1 parent 5352198 commit 7e2d4f5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
36 changes: 21 additions & 15 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,33 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
} else {
// Cluster is not using ClusterClass, upgrade via individual resources.
By("Upgrading the Kubernetes control-plane")
var upgradeMachineTemplateTo *string
if input.E2EConfig.HasVariable(MachineTemplateUpgradeTo) {
upgradeMachineTemplateTo = pointer.StringPtr(input.E2EConfig.GetVariable(MachineTemplateUpgradeTo))
}
framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{
ClusterProxy: input.BootstrapClusterProxy,
Cluster: clusterResources.Cluster,
ControlPlane: clusterResources.ControlPlane,
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
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"),
ClusterProxy: input.BootstrapClusterProxy,
Cluster: clusterResources.Cluster,
ControlPlane: clusterResources.ControlPlane,
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
KubernetesUpgradeMachineTemplate: upgradeMachineTemplateTo,
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: input.BootstrapClusterProxy,
Cluster: clusterResources.Cluster,
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
MachineDeployments: clusterResources.MachineDeployments,
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
ClusterProxy: input.BootstrapClusterProxy,
Cluster: clusterResources.Cluster,
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
KubernetesUpgradeMachineTemplate: upgradeMachineTemplateTo,
MachineDeployments: clusterResources.MachineDeployments,
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
})
}
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
CNIResources = "CNI_RESOURCES"
KubernetesVersionUpgradeFrom = "KUBERNETES_VERSION_UPGRADE_FROM"
KubernetesVersionUpgradeTo = "KUBERNETES_VERSION_UPGRADE_TO"
MachineTemplateUpgradeTo = "MACHINE_TEMPLATE_UPGRADE_TO"
EtcdVersionUpgradeTo = "ETCD_VERSION_UPGRADE_TO"
CoreDNSVersionUpgradeTo = "COREDNS_VERSION_UPGRADE_TO"
IPFamily = "IP_FAMILY"
Expand Down
25 changes: 14 additions & 11 deletions test/framework/controlplane_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,17 @@ func WaitForControlPlaneAndMachinesReady(ctx context.Context, input WaitForContr

// UpgradeControlPlaneAndWaitForUpgradeInput is the input type for UpgradeControlPlaneAndWaitForUpgrade.
type UpgradeControlPlaneAndWaitForUpgradeInput struct {
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
ControlPlane *controlplanev1.KubeadmControlPlane
KubernetesUpgradeVersion string
EtcdImageTag string
DNSImageTag string
WaitForMachinesToBeUpgraded []interface{}
WaitForDNSUpgrade []interface{}
WaitForKubeProxyUpgrade []interface{}
WaitForEtcdUpgrade []interface{}
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
ControlPlane *controlplanev1.KubeadmControlPlane
KubernetesUpgradeVersion string
KubernetesUpgradeMachineTemplate *string
EtcdImageTag string
DNSImageTag string
WaitForMachinesToBeUpgraded []interface{}
WaitForDNSUpgrade []interface{}
WaitForKubeProxyUpgrade []interface{}
WaitForEtcdUpgrade []interface{}
}

// UpgradeControlPlaneAndWaitForUpgrade upgrades a KubeadmControlPlane and waits for it to be upgraded.
Expand All @@ -310,7 +311,9 @@ func UpgradeControlPlaneAndWaitForUpgrade(ctx context.Context, input UpgradeCont
Expect(err).ToNot(HaveOccurred())

input.ControlPlane.Spec.Version = input.KubernetesUpgradeVersion

if input.KubernetesUpgradeMachineTemplate != nil {
input.ControlPlane.Spec.MachineTemplate.InfrastructureRef.Name = *input.KubernetesUpgradeMachineTemplate
}
// If the ClusterConfiguration is not specified, create an empty one.
if input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration == nil {
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration = new(bootstrapv1.ClusterConfiguration)
Expand Down
14 changes: 9 additions & 5 deletions test/framework/machinedeployment_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ func DiscoveryAndWaitForMachineDeployments(ctx context.Context, input DiscoveryA

// UpgradeMachineDeploymentsAndWaitInput is the input type for UpgradeMachineDeploymentsAndWait.
type UpgradeMachineDeploymentsAndWaitInput struct {
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
UpgradeVersion string
MachineDeployments []*clusterv1.MachineDeployment
WaitForMachinesToBeUpgraded []interface{}
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
UpgradeVersion string
KubernetesUpgradeMachineTemplate *string
MachineDeployments []*clusterv1.MachineDeployment
WaitForMachinesToBeUpgraded []interface{}
}

// UpgradeMachineDeploymentsAndWait upgrades a machine deployment and waits for its machines to be upgraded.
Expand All @@ -174,6 +175,9 @@ func UpgradeMachineDeploymentsAndWait(ctx context.Context, input UpgradeMachineD

oldVersion := deployment.Spec.Template.Spec.Version
deployment.Spec.Template.Spec.Version = &input.UpgradeVersion
if input.KubernetesUpgradeMachineTemplate != nil {
deployment.Spec.Template.Spec.InfrastructureRef.Name = *input.KubernetesUpgradeMachineTemplate
}
Expect(patchHelper.Patch(ctx, deployment)).To(Succeed())

log.Logf("Waiting for Kubernetes versions of machines in MachineDeployment %s/%s to be upgraded from %s to %s",
Expand Down

0 comments on commit 7e2d4f5

Please sign in to comment.