mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Added e2e test for local-volume provisioner that does not create PV for discovered non-bind-mounted filesystem.
Inspect daemonset provisioner logs for validation. The logs are examined for the log lines showing that the provisioner discovered the directories and did NOT create a local PV. This commit also adds SkipUnlessProvider supports SSH, which is required for local PV e2e tests.
This commit is contained in:
parent
f389b0a02b
commit
6e53b1a313
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user