Skip to content

Commit 6d1cd8d

Browse files
authored
Merge pull request kubernetes-sigs#9963 from sbueringer/pr-etcd-coredns-opt
🌱 Make etcd and CoreDNS optional in upgrade and self-hosted tests
2 parents 572a971 + 55ad817 commit 6d1cd8d

File tree

5 files changed

+53
-33
lines changed

5 files changed

+53
-33
lines changed

test/e2e/cluster_upgrade.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
8484
controlPlaneMachineCount int64
8585
workerMachineCount int64
8686

87+
etcdVersionUpgradeTo string
88+
coreDNSVersionUpgradeTo string
89+
8790
clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult
8891
kubetestConfigFilePath string
8992
)
@@ -98,8 +101,6 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
98101

99102
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeFrom))
100103
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeTo))
101-
Expect(input.E2EConfig.Variables).To(HaveKey(EtcdVersionUpgradeTo))
102-
Expect(input.E2EConfig.Variables).To(HaveKey(CoreDNSVersionUpgradeTo))
103104

104105
Expect(input.E2EConfig.Variables).To(HaveKey(kubetestConfigurationVariable), "% spec requires a %s variable to be defined in the config file", specName, kubetestConfigurationVariable)
105106
kubetestConfigFilePath = input.E2EConfig.GetVariable(kubetestConfigurationVariable)
@@ -117,6 +118,13 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
117118
workerMachineCount = *input.WorkerMachineCount
118119
}
119120

121+
if input.E2EConfig.HasVariable(EtcdVersionUpgradeTo) {
122+
etcdVersionUpgradeTo = input.E2EConfig.GetVariable(EtcdVersionUpgradeTo)
123+
}
124+
if input.E2EConfig.HasVariable(CoreDNSVersionUpgradeTo) {
125+
coreDNSVersionUpgradeTo = input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo)
126+
}
127+
120128
// Setup a Namespace where to host objects for this spec and create a watcher for the Namespace events.
121129
namespace, cancelWatches = setupSpecNamespace(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder)
122130
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
@@ -158,8 +166,8 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
158166
ClusterProxy: input.BootstrapClusterProxy,
159167
Cluster: clusterResources.Cluster,
160168
ControlPlane: clusterResources.ControlPlane,
161-
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
162-
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
169+
EtcdImageTag: etcdVersionUpgradeTo,
170+
DNSImageTag: coreDNSVersionUpgradeTo,
163171
MachineDeployments: clusterResources.MachineDeployments,
164172
MachinePools: clusterResources.MachinePools,
165173
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
@@ -189,8 +197,8 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
189197
ClusterProxy: input.BootstrapClusterProxy,
190198
Cluster: clusterResources.Cluster,
191199
ControlPlane: clusterResources.ControlPlane,
192-
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
193-
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
200+
EtcdImageTag: etcdVersionUpgradeTo,
201+
DNSImageTag: coreDNSVersionUpgradeTo,
194202
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
195203
UpgradeMachineTemplate: upgradeCPMachineTemplateTo,
196204
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ func clusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() cl
116116

117117
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeFrom))
118118
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeTo))
119-
Expect(input.E2EConfig.Variables).To(HaveKey(EtcdVersionUpgradeTo))
120-
Expect(input.E2EConfig.Variables).To(HaveKey(CoreDNSVersionUpgradeTo))
121119

122120
if input.ControlPlaneMachineCount == nil {
123121
controlPlaneMachineCount = 1

test/e2e/self_hosted.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
9494
controlPlaneMachineCount int64
9595
workerMachineCount int64
9696

97+
etcdVersionUpgradeTo string
98+
coreDNSVersionUpgradeTo string
99+
97100
kubernetesVersion string
98101
)
99102

@@ -113,10 +116,15 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
113116
} else {
114117
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeFrom))
115118
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersionUpgradeTo))
116-
Expect(input.E2EConfig.Variables).To(HaveKey(EtcdVersionUpgradeTo))
117-
Expect(input.E2EConfig.Variables).To(HaveKey(CoreDNSVersionUpgradeTo))
118119

119120
kubernetesVersion = input.E2EConfig.GetVariable(KubernetesVersionUpgradeFrom)
121+
122+
if input.E2EConfig.HasVariable(EtcdVersionUpgradeTo) {
123+
etcdVersionUpgradeTo = input.E2EConfig.GetVariable(EtcdVersionUpgradeTo)
124+
}
125+
if input.E2EConfig.HasVariable(CoreDNSVersionUpgradeTo) {
126+
coreDNSVersionUpgradeTo = input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo)
127+
}
120128
}
121129

122130
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
@@ -314,8 +322,8 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
314322
ClusterProxy: selfHostedClusterProxy,
315323
Cluster: clusterResources.Cluster,
316324
ControlPlane: clusterResources.ControlPlane,
317-
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
318-
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
325+
EtcdImageTag: etcdVersionUpgradeTo,
326+
DNSImageTag: coreDNSVersionUpgradeTo,
319327
MachineDeployments: clusterResources.MachineDeployments,
320328
MachinePools: clusterResources.MachinePools,
321329
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
@@ -345,8 +353,8 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
345353
ClusterProxy: selfHostedClusterProxy,
346354
Cluster: clusterResources.Cluster,
347355
ControlPlane: clusterResources.ControlPlane,
348-
EtcdImageTag: input.E2EConfig.GetVariable(EtcdVersionUpgradeTo),
349-
DNSImageTag: input.E2EConfig.GetVariable(CoreDNSVersionUpgradeTo),
356+
EtcdImageTag: etcdVersionUpgradeTo,
357+
DNSImageTag: coreDNSVersionUpgradeTo,
350358
KubernetesUpgradeVersion: input.E2EConfig.GetVariable(KubernetesVersionUpgradeTo),
351359
UpgradeMachineTemplate: upgradeCPMachineTemplateTo,
352360
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),

test/framework/cluster_topology_helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ func UpgradeClusterTopologyAndWaitForUpgrade(ctx context.Context, input UpgradeC
9494

9595
input.Cluster.Spec.Topology.Version = input.KubernetesUpgradeVersion
9696
for i, variable := range input.Cluster.Spec.Topology.Variables {
97-
if variable.Name == "etcdImageTag" {
97+
if input.EtcdImageTag != "" && variable.Name == "etcdImageTag" {
9898
// NOTE: strconv.Quote is used to produce a valid JSON string.
9999
input.Cluster.Spec.Topology.Variables[i].Value = apiextensionsv1.JSON{Raw: []byte(strconv.Quote(input.EtcdImageTag))}
100100
}
101-
if variable.Name == "coreDNSImageTag" {
101+
if input.DNSImageTag != "" && variable.Name == "coreDNSImageTag" {
102102
// NOTE: strconv.Quote is used to produce a valid JSON string.
103103
input.Cluster.Spec.Topology.Variables[i].Value = apiextensionsv1.JSON{Raw: []byte(strconv.Quote(input.DNSImageTag))}
104104
}

test/framework/controlplane_helpers.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ func UpgradeControlPlaneAndWaitForUpgrade(ctx context.Context, input UpgradeCont
326326
Expect(input.Cluster).ToNot(BeNil(), "Invalid argument. input.Cluster can't be nil when calling UpgradeControlPlaneAndWaitForUpgrade")
327327
Expect(input.ControlPlane).ToNot(BeNil(), "Invalid argument. input.ControlPlane can't be nil when calling UpgradeControlPlaneAndWaitForUpgrade")
328328
Expect(input.KubernetesUpgradeVersion).ToNot(BeNil(), "Invalid argument. input.KubernetesUpgradeVersion can't be empty when calling UpgradeControlPlaneAndWaitForUpgrade")
329-
Expect(input.EtcdImageTag).ToNot(BeNil(), "Invalid argument. input.EtcdImageTag can't be empty when calling UpgradeControlPlaneAndWaitForUpgrade")
330-
Expect(input.DNSImageTag).ToNot(BeNil(), "Invalid argument. input.DNSImageTag can't be empty when calling UpgradeControlPlaneAndWaitForUpgrade")
331329

332330
mgmtClient := input.ClusterProxy.GetClient()
333331

@@ -348,8 +346,12 @@ func UpgradeControlPlaneAndWaitForUpgrade(ctx context.Context, input UpgradeCont
348346
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local = new(bootstrapv1.LocalEtcd)
349347
}
350348

351-
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local.ImageMeta.ImageTag = input.EtcdImageTag
352-
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.ImageMeta.ImageTag = input.DNSImageTag
349+
if input.EtcdImageTag != "" {
350+
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd.Local.ImageMeta.ImageTag = input.EtcdImageTag
351+
}
352+
if input.DNSImageTag != "" {
353+
input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.ImageMeta.ImageTag = input.DNSImageTag
354+
}
353355

354356
Eventually(func() error {
355357
return patchHelper.Patch(ctx, input.ControlPlane)
@@ -371,20 +373,24 @@ func UpgradeControlPlaneAndWaitForUpgrade(ctx context.Context, input UpgradeCont
371373
KubernetesVersion: input.KubernetesUpgradeVersion,
372374
}, input.WaitForKubeProxyUpgrade...)
373375

374-
log.Logf("Waiting for CoreDNS to have the upgraded image tag")
375-
WaitForDNSUpgrade(ctx, WaitForDNSUpgradeInput{
376-
Getter: workloadClient,
377-
DNSVersion: input.DNSImageTag,
378-
}, input.WaitForDNSUpgrade...)
376+
if input.DNSImageTag != "" {
377+
log.Logf("Waiting for CoreDNS to have the upgraded image tag")
378+
WaitForDNSUpgrade(ctx, WaitForDNSUpgradeInput{
379+
Getter: workloadClient,
380+
DNSVersion: input.DNSImageTag,
381+
}, input.WaitForDNSUpgrade...)
382+
}
379383

380-
log.Logf("Waiting for etcd to have the upgraded image tag")
381-
lblSelector, err := labels.Parse("component=etcd")
382-
Expect(err).ToNot(HaveOccurred())
383-
WaitForPodListCondition(ctx, WaitForPodListConditionInput{
384-
Lister: workloadClient,
385-
ListOptions: &client.ListOptions{LabelSelector: lblSelector},
386-
Condition: EtcdImageTagCondition(input.EtcdImageTag, int(*input.ControlPlane.Spec.Replicas)),
387-
}, input.WaitForEtcdUpgrade...)
384+
if input.EtcdImageTag != "" {
385+
log.Logf("Waiting for etcd to have the upgraded image tag")
386+
lblSelector, err := labels.Parse("component=etcd")
387+
Expect(err).ToNot(HaveOccurred())
388+
WaitForPodListCondition(ctx, WaitForPodListConditionInput{
389+
Lister: workloadClient,
390+
ListOptions: &client.ListOptions{LabelSelector: lblSelector},
391+
Condition: EtcdImageTagCondition(input.EtcdImageTag, int(*input.ControlPlane.Spec.Replicas)),
392+
}, input.WaitForEtcdUpgrade...)
393+
}
388394
}
389395

390396
// controlPlaneMachineOptions returns a set of ListOptions that allows to get all machine objects belonging to control plane.

0 commit comments

Comments
 (0)