Skip to content

Commit e69a5ed

Browse files
authored
Merge pull request kubernetes#129200 from carlory/remove-GetDeviceNameFromMount
Remove GetDeviceNameFromMount from HostUtils
2 parents ddfd02d + d397406 commit e69a5ed

File tree

2 files changed

+0
-77
lines changed

2 files changed

+0
-77
lines changed

pkg/volume/util/hostutil/hostutil.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package hostutil
1919
import (
2020
"fmt"
2121
"os"
22-
23-
"k8s.io/mount-utils"
2422
)
2523

2624
// FileType enumerates the known set of possible file types.
@@ -52,10 +50,6 @@ type HostUtils interface {
5250
DeviceOpened(pathname string) (bool, error)
5351
// PathIsDevice determines if a path is a device.
5452
PathIsDevice(pathname string) (bool, error)
55-
// GetDeviceNameFromMount finds the device name by checking the mount path
56-
// to get the global mount path within its plugin directory.
57-
// TODO: Remove this method once the rbd and vsphere plugins are removed from in-tree.
58-
GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error)
5953
// MakeRShared checks that given path is on a mount with 'rshared' mount
6054
// propagation. If not, it bind-mounts the path as rshared.
6155
MakeRShared(path string) error

pkg/volume/util/hostutil/hostutil_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package hostutil
1818

1919
import (
20-
"errors"
2120
"fmt"
2221
"net"
2322
"os"
@@ -26,79 +25,9 @@ import (
2625
"strings"
2726
"testing"
2827

29-
"github.com/stretchr/testify/assert"
30-
"k8s.io/mount-utils"
3128
"k8s.io/utils/exec"
3229
)
3330

34-
// fakeMounter implements mount.Interface for tests.
35-
type fakeMounter struct {
36-
mount.FakeMounter
37-
mountRefs []string
38-
raiseError bool
39-
}
40-
41-
// GetMountRefs finds all mount references to the path, returns a
42-
// list of paths.
43-
func (f *fakeMounter) GetMountRefs(pathname string) ([]string, error) {
44-
if f.raiseError {
45-
return nil, errors.New("Expected error.")
46-
}
47-
48-
return f.mountRefs, nil
49-
}
50-
51-
func TestDeviceNameFromMount(t *testing.T) {
52-
hu := NewHostUtil()
53-
path := "/tmp/foo"
54-
if goruntime.GOOS == "windows" {
55-
path = "C:" + path
56-
}
57-
58-
testCases := map[string]struct {
59-
mountRefs []string
60-
expectedPath string
61-
raiseError bool
62-
expectedError string
63-
}{
64-
"GetMountRefs error": {
65-
raiseError: true,
66-
expectedError: "Expected error.",
67-
},
68-
"No Refs error": {
69-
expectedError: fmt.Sprintf("directory %s is not mounted", path),
70-
},
71-
"No Matching refs": {
72-
mountRefs: []string{filepath.Join("foo", "lish")},
73-
expectedPath: filepath.Base(path),
74-
},
75-
"Matched ref": {
76-
mountRefs: []string{filepath.Join(path, "lish")},
77-
expectedPath: "lish",
78-
},
79-
}
80-
81-
for name, tc := range testCases {
82-
t.Run(name, func(t *testing.T) {
83-
mounter := &fakeMounter{
84-
mountRefs: tc.mountRefs,
85-
raiseError: tc.raiseError,
86-
}
87-
88-
path, err := hu.GetDeviceNameFromMount(mounter, path, path)
89-
if tc.expectedError != "" {
90-
if err == nil || err.Error() != tc.expectedError {
91-
t.Fatalf("expected error message `%s` but got `%v`", tc.expectedError, err)
92-
}
93-
return
94-
}
95-
96-
expectedPath := filepath.FromSlash(tc.expectedPath)
97-
assert.Equal(t, expectedPath, path)
98-
})
99-
}
100-
}
101-
10231
func createSocketFile(socketDir string) (string, error) {
10332
testSocketFile := filepath.Join(socketDir, "mt.sock")
10433

0 commit comments

Comments
 (0)