From 18f0802852556cb68aa3c2e263eaa5a66b361732 Mon Sep 17 00:00:00 2001 From: edisonxiang Date: Wed, 22 Nov 2017 14:19:12 +0800 Subject: [PATCH 1/2] fix controlplane unit tests What this PR does / why we need it: when the flexvolumeDirVolumePath is truely existent in the host, ```cmd/kubeadm/app/phases/controlplane``` unit tests will be failed. Fixes #56189 Release note: ```release-note NONE ``` --- cmd/kubeadm/app/phases/controlplane/volumes_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/kubeadm/app/phases/controlplane/volumes_test.go b/cmd/kubeadm/app/phases/controlplane/volumes_test.go index b2cdacadbaa..d771739e99f 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes_test.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes_test.go @@ -513,6 +513,15 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { for _, rt := range tests { mounts := getHostPathVolumesForTheControlPlane(rt.cfg) + + // Avoid unit test errors when the flexvolume is mounted + if _, ok := mounts.volumes[kubeadmconstants.KubeControllerManager][flexvolumeDirVolumeName]; ok { + delete(mounts.volumes[kubeadmconstants.KubeControllerManager], flexvolumeDirVolumeName) + } + if _, ok := mounts.volumeMounts[kubeadmconstants.KubeControllerManager][flexvolumeDirVolumeName]; ok { + delete(mounts.volumeMounts[kubeadmconstants.KubeControllerManager], flexvolumeDirVolumeName) + } + if !reflect.DeepEqual(mounts.volumes, rt.vol) { t.Errorf( "failed getHostPathVolumesForTheControlPlane:\n\texpected: %v\n\t actual: %v", From 29d42afe085788fa8cf82bf4980f648056c89964 Mon Sep 17 00:00:00 2001 From: edisonxiang Date: Wed, 22 Nov 2017 19:58:59 +0800 Subject: [PATCH 2/2] fix fmt wording error --- cmd/kubeadm/app/phases/controlplane/volumes_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/phases/controlplane/volumes_test.go b/cmd/kubeadm/app/phases/controlplane/volumes_test.go index d771739e99f..daa824062c2 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes_test.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes_test.go @@ -514,7 +514,7 @@ func TestGetHostPathVolumesForTheControlPlane(t *testing.T) { for _, rt := range tests { mounts := getHostPathVolumesForTheControlPlane(rt.cfg) - // Avoid unit test errors when the flexvolume is mounted + // Avoid unit test errors when the flexvolume is mounted if _, ok := mounts.volumes[kubeadmconstants.KubeControllerManager][flexvolumeDirVolumeName]; ok { delete(mounts.volumes[kubeadmconstants.KubeControllerManager], flexvolumeDirVolumeName) }