From 1b710a4c56c2eb9108bb50023ce7bbe60c0859b1 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 24 Feb 2020 16:41:03 +0200 Subject: [PATCH] kubeadm: modify how component volumes are printed After the shift for init phases, GetStaticPodSpecs() from app/phases/controlplane/manifests.go gets called on each control-plane component sub-phase. This ends up calling the Printf from AddExtraHostPathMounts() in app/phases/controlplane/volumes.go multiple times printing the same volumes for different components. - Remove the Printf call from AddExtraHostPathMounts(). - Print all volumes for a component in CreateStaticPodFiles() using klog V(2). Perhaps in the future a bigger refactor is needed here were a single control-plane component spec can be requested instead of a map[string]v1.Pod. --- cmd/kubeadm/app/phases/controlplane/manifests.go | 5 +++++ cmd/kubeadm/app/phases/controlplane/volumes.go | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/phases/controlplane/manifests.go b/cmd/kubeadm/app/phases/controlplane/manifests.go index e9a778048ca..ae9cd77e259 100644 --- a/cmd/kubeadm/app/phases/controlplane/manifests.go +++ b/cmd/kubeadm/app/phases/controlplane/manifests.go @@ -99,6 +99,11 @@ func CreateStaticPodFiles(manifestDir, kustomizeDir string, cfg *kubeadmapi.Clus return errors.Errorf("couldn't retrieve StaticPodSpec for %q", componentName) } + // print all volumes that are mounted + for _, v := range spec.Spec.Volumes { + klog.V(2).Infof("[control-plane] adding volume %q for component %q", v.Name, componentName) + } + // if kustomizeDir is defined, customize the static pod manifest if kustomizeDir != "" { kustomizedSpec, err := staticpodutil.KustomizeStaticPod(&spec, kustomizeDir) diff --git a/cmd/kubeadm/app/phases/controlplane/volumes.go b/cmd/kubeadm/app/phases/controlplane/volumes.go index 053f47fd66d..7f2f7ceec52 100644 --- a/cmd/kubeadm/app/phases/controlplane/volumes.go +++ b/cmd/kubeadm/app/phases/controlplane/volumes.go @@ -144,7 +144,6 @@ func (c *controlPlaneHostPathMounts) AddHostPathMounts(component string, vols [] // paths in the case that a user specifies the same volume/volume mount name. func (c *controlPlaneHostPathMounts) AddExtraHostPathMounts(component string, extraVols []kubeadmapi.HostPathMount) { for _, extraVol := range extraVols { - fmt.Printf("[control-plane] Adding extra host path mount %q to %q\n", extraVol.Name, component) hostPathType := extraVol.PathType c.NewHostPathMount(component, extraVol.Name, extraVol.HostPath, extraVol.MountPath, extraVol.ReadOnly, &hostPathType) }