Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [E2E] allow provider specific infra machine template for upgrade tests #6075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,18 @@ 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),
UpgradeMachineTemplate: 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"),
Expand All @@ -173,6 +178,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
ClusterProxy: input.BootstrapClusterProxy,
Cluster: clusterResources.Cluster,
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
UpgradeMachineTemplate: 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
5 changes: 4 additions & 1 deletion test/framework/controlplane_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ type UpgradeControlPlaneAndWaitForUpgradeInput struct {
Cluster *clusterv1.Cluster
ControlPlane *controlplanev1.KubeadmControlPlane
KubernetesUpgradeVersion string
UpgradeMachineTemplate *string
EtcdImageTag string
DNSImageTag string
WaitForMachinesToBeUpgraded []interface{}
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.UpgradeMachineTemplate != nil {
input.ControlPlane.Spec.MachineTemplate.InfrastructureRef.Name = *input.UpgradeMachineTemplate
}
// 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
4 changes: 4 additions & 0 deletions test/framework/machinedeployment_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ type UpgradeMachineDeploymentsAndWaitInput struct {
ClusterProxy ClusterProxy
Cluster *clusterv1.Cluster
UpgradeVersion string
UpgradeMachineTemplate *string
MachineDeployments []*clusterv1.MachineDeployment
WaitForMachinesToBeUpgraded []interface{}
}
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.UpgradeMachineTemplate != nil {
deployment.Spec.Template.Spec.InfrastructureRef.Name = *input.UpgradeMachineTemplate
}
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