Skip to content

Commit af22cc8

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#61019 from ianchakeres/e2e-lv-prov-bind-disc
Automatic merge from submit-queue (batch tested with PRs 61644, 61624, 61743, 61019, 61287). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Added e2e test for local-volume provisioner that does not create PV for discovered non-bind-mounted filesystem. **What this PR does / why we need it**: For v2+ of the [local volume provisioner](https://github.com/kubernetes-incubator/external-storage/tree/master/local-volume) non-bind mounted filesystems in a discovery directory will no longer result in local PVs. This change was put in place to handle the non-atomic nature of other methods of adding directories (e.g. kubernetes-retired/external-storage#482). This PR tests this change in behavior, and it validates that non-bind mounted directories within a discovery directory do NOT result in a local PV. **Which issue(s) this PR fixes**: Fixes kubernetes#61020 **Special notes for your reviewer**: This test can be executed using the following commands: ``` KUBE_FEATURE_GATES="BlockVolume=true" NUM_NODES=1 go run hack/e2e.go -- --up go run hack/e2e.go -- --test --test_args='--ginkgo.focus=PersistentVolumes-local.*Local.*volume.*provisioner' ``` If you get the logs from a local volume provisioner pod, you will see the following log messages: ``` $ kubectl logs local-volume-provisioner-94ddb -n e2e-tests-persistent-local-volumes-test-6ls4z <snip> I0311 19:01:30.350504 1 controller.go:73] Controller started E0311 19:01:30.350849 1 discovery.go:172] Path "/mnt/local-storage/notbindmount" is not an actual mountpoint ``` **Release note**: ```release-note NONE ```
2 parents 2edeb07 + 6e53b1a commit af22cc8

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/e2e/storage/persistent_volumes-local.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() {
159159
)
160160

161161
BeforeEach(func() {
162+
framework.SkipUnlessProviderIs(framework.ProvidersWithSSH...)
163+
162164
// Get all the schedulable nodes
163165
nodes := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
164166
Expect(len(nodes.Items)).NotTo(BeZero(), "No available nodes for scheduling")
@@ -403,6 +405,32 @@ var _ = utils.SIGDescribe("PersistentVolumes-local ", func() {
403405
By("Deleting provisioner daemonset")
404406
deleteProvisionerDaemonset(config)
405407
})
408+
It("should not create local persistent volume for filesystem volume that was not bind mounted", func() {
409+
410+
directoryPath := filepath.Join(config.discoveryDir, "notbindmount")
411+
By("Creating a directory, not bind mounted, in discovery directory")
412+
mkdirCmd := fmt.Sprintf("mkdir -p %v -m 777", directoryPath)
413+
err := framework.IssueSSHCommand(mkdirCmd, framework.TestContext.Provider, config.node0)
414+
Expect(err).NotTo(HaveOccurred())
415+
416+
By("Starting a provisioner daemonset")
417+
createProvisionerDaemonset(config)
418+
419+
By("Allowing provisioner to run for 30s and discover potential local PVs")
420+
time.Sleep(30 * time.Second)
421+
422+
By("Examining provisioner logs for not an actual mountpoint message")
423+
provisionerPodName := findProvisionerDaemonsetPodName(config)
424+
logs, err := framework.GetPodLogs(config.client, config.ns, provisionerPodName, "" /*containerName*/)
425+
Expect(err).NotTo(HaveOccurred(),
426+
"Error getting logs from pod %s in namespace %s", provisionerPodName, config.ns)
427+
428+
expectedLogMessage := "Path \"/mnt/local-storage/notbindmount\" is not an actual mountpoint"
429+
Expect(strings.Contains(logs, expectedLogMessage)).To(BeTrue())
430+
431+
By("Deleting provisioner daemonset")
432+
deleteProvisionerDaemonset(config)
433+
})
406434
It("should discover dynamicly created local persistent volume mountpoint in discovery directory", func() {
407435
By("Starting a provisioner daemonset")
408436
createProvisionerDaemonset(config)
@@ -1397,6 +1425,22 @@ func createProvisionerDaemonset(config *localTestConfig) {
13971425
framework.WaitForControlledPodsRunning(config.client, config.ns, daemonSetName, kind)
13981426
}
13991427

1428+
func findProvisionerDaemonsetPodName(config *localTestConfig) string {
1429+
podList, err := config.client.CoreV1().Pods(config.ns).List(metav1.ListOptions{})
1430+
if err != nil {
1431+
framework.Failf("could not get the pod list: %v", err)
1432+
return ""
1433+
}
1434+
pods := podList.Items
1435+
for _, pod := range pods {
1436+
if strings.HasPrefix(pod.Name, daemonSetName) && pod.Spec.NodeName == config.node0.Name {
1437+
return pod.Name
1438+
}
1439+
}
1440+
framework.Failf("Unable to find provisioner daemonset pod on node0")
1441+
return ""
1442+
}
1443+
14001444
func deleteProvisionerDaemonset(config *localTestConfig) {
14011445
ds, err := config.client.ExtensionsV1beta1().DaemonSets(config.ns).Get(daemonSetName, metav1.GetOptions{})
14021446
if ds == nil {

0 commit comments

Comments
 (0)