From 7601ebddedd5aee436172ab3faa30467b75573ac Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Tue, 31 Aug 2021 16:24:08 -0400 Subject: [PATCH] [e2e framework] Avoid NPE when KCP does not specify ClusterConfiguration KubeadmControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration is not a required field, avoid assuming it is set in the e2e framework. --- test/framework/controlplane_helpers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/framework/controlplane_helpers.go b/test/framework/controlplane_helpers.go index 095d90901f49..1f1040ba61cb 100644 --- a/test/framework/controlplane_helpers.go +++ b/test/framework/controlplane_helpers.go @@ -300,6 +300,12 @@ func UpgradeControlPlaneAndWaitForUpgrade(ctx context.Context, input UpgradeCont Expect(err).ToNot(HaveOccurred()) input.ControlPlane.Spec.Version = input.KubernetesUpgradeVersion + + // 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) + } + input.ControlPlane.Spec.KubeadmConfigSpec.ClusterConfiguration.Etcd = bootstrapv1.Etcd{ Local: &bootstrapv1.LocalEtcd{ ImageMeta: bootstrapv1.ImageMeta{