Skip to content

Commit 83af791

Browse files
authored
Merge pull request #6075 from aartij17/add-machinetemplate-flag
✨ allow provider specific infra machine template for upgrade tests
2 parents d38a4b1 + 20a0a9a commit 83af791

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

test/e2e/cluster_upgrade.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,18 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
154154
} else {
155155
// Cluster is not using ClusterClass, upgrade via individual resources.
156156
By("Upgrading the Kubernetes control-plane")
157+
var upgradeMachineTemplateTo *string
158+
if input.E2EConfig.HasVariable(MachineTemplateUpgradeTo) {
159+
upgradeMachineTemplateTo = pointer.StringPtr(input.E2EConfig.GetVariable(MachineTemplateUpgradeTo))
160+
}
157161
framework.UpgradeControlPlaneAndWaitForUpgrade(ctx, framework.UpgradeControlPlaneAndWaitForUpgradeInput{
158162
ClusterProxy: input.BootstrapClusterProxy,
159163
Cluster: clusterResources.Cluster,
160164
ControlPlane: clusterResources.ControlPlane,
161165
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
162166
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
163167
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
168+
UpgradeMachineTemplate: upgradeMachineTemplateTo,
164169
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
165170
WaitForKubeProxyUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
166171
WaitForDNSUpgrade: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
@@ -173,6 +178,7 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
173178
ClusterProxy: input.BootstrapClusterProxy,
174179
Cluster: clusterResources.Cluster,
175180
UpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
181+
UpgradeMachineTemplate: upgradeMachineTemplateTo,
176182
MachineDeployments: clusterResources.MachineDeployments,
177183
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
178184
})

test/e2e/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const (
3939
CNIResources = "CNI_RESOURCES"
4040
KubernetesVersionUpgradeFrom = "KUBERNETES_VERSION_UPGRADE_FROM"
4141
KubernetesVersionUpgradeTo = "KUBERNETES_VERSION_UPGRADE_TO"
42+
MachineTemplateUpgradeTo = "MACHINE_TEMPLATE_UPGRADE_TO"
4243
EtcdVersionUpgradeTo = "ETCD_VERSION_UPGRADE_TO"
4344
CoreDNSVersionUpgradeTo = "COREDNS_VERSION_UPGRADE_TO"
4445
IPFamily = "IP_FAMILY"

test/framework/controlplane_helpers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ type UpgradeControlPlaneAndWaitForUpgradeInput struct {
285285
Cluster *clusterv1.Cluster
286286
ControlPlane *controlplanev1.KubeadmControlPlane
287287
KubernetesUpgradeVersion string
288+
UpgradeMachineTemplate *string
288289
EtcdImageTag string
289290
DNSImageTag string
290291
WaitForMachinesToBeUpgraded []interface{}
@@ -310,7 +311,9 @@ func UpgradeControlPlaneAndWaitForUpgrade(ctx context.Context, input UpgradeCont
310311
Expect(err).ToNot(HaveOccurred())
311312

312313
input.ControlPlane.Spec.Version = input.KubernetesUpgradeVersion
313-
314+
if input.UpgradeMachineTemplate != nil {
315+
input.ControlPlane.Spec.MachineTemplate.InfrastructureRef.Name = *input.UpgradeMachineTemplate
316+
}
314317
// If the ClusterConfiguration is not specified, create an empty one.
315318
if input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration == nil {
316319
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration = new(bootstrapv1.ClusterConfiguration)

test/framework/machinedeployment_helpers.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ type UpgradeMachineDeploymentsAndWaitInput struct {
153153
ClusterProxy ClusterProxy
154154
Cluster *clusterv1.Cluster
155155
UpgradeVersion string
156+
UpgradeMachineTemplate *string
156157
MachineDeployments []*clusterv1.MachineDeployment
157158
WaitForMachinesToBeUpgraded []interface{}
158159
}
@@ -174,6 +175,9 @@ func UpgradeMachineDeploymentsAndWait(ctx context.Context, input UpgradeMachineD
174175

175176
oldVersion := deployment.Spec.Template.Spec.Version
176177
deployment.Spec.Template.Spec.Version = &input.UpgradeVersion
178+
if input.UpgradeMachineTemplate != nil {
179+
deployment.Spec.Template.Spec.InfrastructureRef.Name = *input.UpgradeMachineTemplate
180+
}
177181
Expect(patchHelper.Patch(ctx, deployment)).To(Succeed())
178182

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

0 commit comments

Comments
 (0)