diff --git a/test/e2e/storage/persistent_volumes-local.go b/test/e2e/storage/persistent_volumes-local.go index 83899f685d8..efe2cf5d37a 100644 --- a/test/e2e/storage/persistent_volumes-local.go +++ b/test/e2e/storage/persistent_volumes-local.go @@ -159,6 +159,8 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { ) BeforeEach(func() { + framework.SkipUnlessProviderIs(framework.ProvidersWithSSH...) + // Get all the schedulable nodes nodes := framework.GetReadySchedulableNodesOrDie(f.ClientSet) Expect(len(nodes.Items)).NotTo(BeZero(), "No available nodes for scheduling") @@ -403,6 +405,32 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() { By("Deleting provisioner daemonset") deleteProvisionerDaemonset(config) }) + It("should not create local persistent volume for filesystem volume that was not bind mounted", func() { + + directoryPath := filepath.Join(config.discoveryDir, "notbindmount") + By("Creating a directory, not bind mounted, in discovery directory") + mkdirCmd := fmt.Sprintf("mkdir -p %v -m 777", directoryPath) + err := framework.IssueSSHCommand(mkdirCmd, framework.TestContext.Provider, config.node0) + Expect(err).NotTo(HaveOccurred()) + + By("Starting a provisioner daemonset") + createProvisionerDaemonset(config) + + By("Allowing provisioner to run for 30s and discover potential local PVs") + time.Sleep(30 * time.Second) + + By("Examining provisioner logs for not an actual mountpoint message") + provisionerPodName := findProvisionerDaemonsetPodName(config) + logs, err := framework.GetPodLogs(config.client, config.ns, provisionerPodName, "" /*containerName*/) + Expect(err).NotTo(HaveOccurred(), + "Error getting logs from pod %s in namespace %s", provisionerPodName, config.ns) + + expectedLogMessage := "Path \"/mnt/local-storage/notbindmount\" is not an actual mountpoint" + Expect(strings.Contains(logs, expectedLogMessage)).To(BeTrue()) + + By("Deleting provisioner daemonset") + deleteProvisionerDaemonset(config) + }) It("should discover dynamicly created local persistent volume mountpoint in discovery directory", func() { By("Starting a provisioner daemonset") createProvisionerDaemonset(config) @@ -1397,6 +1425,22 @@ func createProvisionerDaemonset(config *localTestConfig) { framework.WaitForControlledPodsRunning(config.client, config.ns, daemonSetName, kind) } +func findProvisionerDaemonsetPodName(config *localTestConfig) string { + podList, err := config.client.CoreV1().Pods(config.ns).List(metav1.ListOptions{}) + if err != nil { + framework.Failf("could not get the pod list: %v", err) + return "" + } + pods := podList.Items + for _, pod := range pods { + if strings.HasPrefix(pod.Name, daemonSetName) && pod.Spec.NodeName == config.node0.Name { + return pod.Name + } + } + framework.Failf("Unable to find provisioner daemonset pod on node0") + return "" +} + func deleteProvisionerDaemonset(config *localTestConfig) { ds, err := config.client.ExtensionsV1beta1().DaemonSets(config.ns).Get(daemonSetName, metav1.GetOptions{}) if ds == nil {