mirror of https://github.com/k3s-io/k3s
RBD Plugin: Prepare to implement Attacher/Detacher interfaces.
1) Fix FakeMounter.IsLikelyNotMountPoint to return ErrNotExist if the directory does not exist. Mounter.IsLikelyNotMountPoint interface requires this, and RBD plugin depends on it.pull/6/head
parent
c0a519be1f
commit
a768092f9a
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package mount
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
|
@ -136,6 +137,11 @@ func (f *FakeMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
|||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
_, err := os.Stat(file)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
// If file is a symlink, get its absolute path
|
||||
absFile, err := filepath.EvalSymlinks(file)
|
||||
if err != nil {
|
||||
|
|
|
@ -18,6 +18,8 @@ package mount
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
|
@ -50,6 +52,11 @@ func TestSafeFormatAndMount(t *testing.T) {
|
|||
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
|
||||
t.Skipf("not supported on GOOS=%s", runtime.GOOS)
|
||||
}
|
||||
mntDir, err := ioutil.TempDir(os.TempDir(), "mount")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create tmp dir: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(mntDir)
|
||||
tests := []struct {
|
||||
description string
|
||||
fstype string
|
||||
|
@ -207,7 +214,7 @@ func TestSafeFormatAndMount(t *testing.T) {
|
|||
}
|
||||
|
||||
device := "/dev/foo"
|
||||
dest := "/mnt/bar"
|
||||
dest := mntDir
|
||||
err := mounter.FormatAndMount(device, dest, test.fstype, test.mountOptions)
|
||||
if test.expectedError == nil {
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue