From 86f20db7d09d1d8171c10505ece6f146fa408cb6 Mon Sep 17 00:00:00 2001 From: David Zhu Date: Thu, 14 Nov 2019 15:39:19 -0800 Subject: [PATCH] Panic on error when creating fake volume host, add a TODO to clean up later --- pkg/volume/testing/testing.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/volume/testing/testing.go b/pkg/volume/testing/testing.go index 5dc99c0a0c4..ebdcb1671ad 100644 --- a/pkg/volume/testing/testing.go +++ b/pkg/volume/testing/testing.go @@ -114,11 +114,16 @@ func newFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins [ host.hostUtil = hostutil.NewFakeHostUtil(pathToTypeMap) host.exec = &testingexec.FakeExec{DisableScripts: true} host.pluginMgr = &VolumePluginMgr{} - host.pluginMgr.InitPlugins(plugins, nil /* prober */, host) + if err := host.pluginMgr.InitPlugins(plugins, nil /* prober */, host); err != nil { + // TODO(dyzz): Pipe testing context through and throw a fatal error instead + panic(fmt.Sprintf("Failed to init plugins while creating fake volume host: %v", err)) + } host.subpather = &subpath.FakeSubpath{} host.informerFactory = informers.NewSharedInformerFactory(kubeClient, time.Minute) // Wait until the InitPlugins setup is finished before returning from this setup func - host.WaitForKubeletErrNil() + if err := host.WaitForKubeletErrNil(); err != nil { + panic(fmt.Sprintf("Failed to wait for kubelet err to be nil while creating fake volume host: %v", err)) + } return host }