Replaces path.Operation with filepath.Operation (kubelet)
The path module has a few different functions: Clean, Split, Join, Ext, Dir, Base, IsAbs. These functions do not take into account the OS-specific path separator, meaning that they won't behave as intended on Windows. For example, Dir is supposed to return all but the last element of the path. For the path "C:\some\dir\somewhere", it is supposed to return "C:\some\dir\", however, it returns ".". Instead of these functions, the ones in filepath should be used instead.
This commit is contained in:
@@ -19,7 +19,6 @@ package reconciler
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -48,8 +47,8 @@ func TestReconstructVolumes(t *testing.T) {
|
||||
{
|
||||
name: "when two pods are using same volume and both are deleted",
|
||||
volumePaths: []string{
|
||||
path.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||
path.Join("pod2", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||
filepath.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||
filepath.Join("pod2", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||
},
|
||||
expectedVolumesNeedReportedInUse: []string{"fake-plugin/pvc-abcdef", "fake-plugin/pvc-abcdef"},
|
||||
expectedVolumesNeedDevicePath: []string{"fake-plugin/pvc-abcdef", "fake-plugin/pvc-abcdef"},
|
||||
@@ -77,7 +76,7 @@ func TestReconstructVolumes(t *testing.T) {
|
||||
{
|
||||
name: "when reconstruction fails for a volume, volumes should be cleaned up",
|
||||
volumePaths: []string{
|
||||
path.Join("pod1", "volumes", "missing-plugin", "pvc-abcdef"),
|
||||
filepath.Join("pod1", "volumes", "missing-plugin", "pvc-abcdef"),
|
||||
},
|
||||
expectedVolumesNeedReportedInUse: []string{},
|
||||
expectedVolumesNeedDevicePath: []string{},
|
||||
@@ -271,14 +270,14 @@ func TestReconstructVolumesMount(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "reconstructed volume is mounted",
|
||||
volumePath: path.Join("pod1uid", "volumes", "fake-plugin", "volumename"),
|
||||
volumePath: filepath.Join("pod1uid", "volumes", "fake-plugin", "volumename"),
|
||||
|
||||
expectMount: true,
|
||||
},
|
||||
{
|
||||
name: "reconstructed volume fails to mount",
|
||||
// FailOnSetupVolumeName: MountDevice succeeds, SetUp fails
|
||||
volumePath: path.Join("pod1uid", "volumes", "fake-plugin", volumetesting.FailOnSetupVolumeName),
|
||||
volumePath: filepath.Join("pod1uid", "volumes", "fake-plugin", volumetesting.FailOnSetupVolumeName),
|
||||
expectMount: false,
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user