diff --git a/pkg/csi-common/server_test.go b/pkg/csi-common/server_test.go index 636bc7eef0c..c7aa2e04027 100644 --- a/pkg/csi-common/server_test.go +++ b/pkg/csi-common/server_test.go @@ -19,6 +19,7 @@ package csicommon import ( "sync" "testing" + "time" "github.com/stretchr/testify/assert" "google.golang.org/grpc" @@ -31,6 +32,8 @@ func TestNewNonBlockingGRPCServer(t *testing.T) { func TestStart(t *testing.T) { s := NewNonBlockingGRPCServer() + // sleep a while to avoid race condition in unit test + time.Sleep(time.Millisecond * 2000) s.Start("tcp://127.0.0.1:0", nil, nil, nil, true) } diff --git a/pkg/mounter/safe_mounter_v1beta_windows.go b/pkg/mounter/safe_mounter_v1beta_windows.go index 0d3894678a2..4fc4dfeaa27 100644 --- a/pkg/mounter/safe_mounter_v1beta_windows.go +++ b/pkg/mounter/safe_mounter_v1beta_windows.go @@ -118,8 +118,9 @@ func (mounter *csiProxyMounterV1Beta) Mount(source string, target string, fstype // Rmdir - delete the given directory // TODO: Call separate rmdir for pod context and plugin context. v1alpha1 for CSI -// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do -// rmdir with either pod or plugin context. +// +// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do +// rmdir with either pod or plugin context. func (mounter *csiProxyMounterV1Beta) Rmdir(path string) error { klog.V(4).Infof("Remove directory: %s", path) rmdirRequest := &fs.RmdirRequest{ @@ -149,8 +150,9 @@ func (mounter *csiProxyMounterV1Beta) IsMountPointMatch(mp mount.MountPoint, dir } // IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error. -// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target -// path is checked. +// +// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target +// path is checked. func (mounter *csiProxyMounterV1Beta) IsLikelyNotMountPoint(path string) (bool, error) { klog.V(4).Infof("IsLikelyNotMountPoint: %s", path) isExists, err := mounter.ExistsPath(path) diff --git a/pkg/mounter/safe_mounter_windows.go b/pkg/mounter/safe_mounter_windows.go index 5fe2564c464..87e58855e2c 100644 --- a/pkg/mounter/safe_mounter_windows.go +++ b/pkg/mounter/safe_mounter_windows.go @@ -145,8 +145,9 @@ func Split(r rune) bool { // Rmdir - delete the given directory // TODO: Call separate rmdir for pod context and plugin context. v1alpha1 for CSI -// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do -// rmdir with either pod or plugin context. +// +// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do +// rmdir with either pod or plugin context. func (mounter *csiProxyMounter) Rmdir(path string) error { klog.V(4).Infof("Remove directory: %s", path) rmdirRequest := &fs.RmdirRequest{ @@ -175,8 +176,9 @@ func (mounter *csiProxyMounter) IsMountPointMatch(mp mount.MountPoint, dir strin } // IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error. -// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target -// path is checked. +// +// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target +// path is checked. func (mounter *csiProxyMounter) IsLikelyNotMountPoint(path string) (bool, error) { klog.V(4).Infof("IsLikelyNotMountPoint: %s", path) isExists, err := mounter.ExistsPath(path) diff --git a/pkg/smb/controllerserver.go b/pkg/smb/controllerserver.go index 10d50178efd..75677fff0f6 100644 --- a/pkg/smb/controllerserver.go +++ b/pkg/smb/controllerserver.go @@ -345,8 +345,8 @@ func newSMBVolume(name string, size int64, params map[string]string) (*smbVolume // Get internal path where the volume is created // The reason why the internal path is "workingDir/subDir/subDir" is because: -// * the semantic is actually "workingDir/volId/subDir" and volId == subDir. -// * we need a mount directory per volId because you can have multiple +// - the semantic is actually "workingDir/volId/subDir" and volId == subDir. +// - we need a mount directory per volId because you can have multiple // CreateVolume calls in parallel and they may use the same underlying share. // Instead of refcounting how many CreateVolume calls are using the same // share, it's simpler to just do a mount per request. @@ -365,8 +365,9 @@ func (d *Driver) smbVolToCSI(vol *smbVolume, parameters map[string]string) *csi. // Given a CSI volume id, return a smbVolume // sample volume Id: -// smb-server.default.svc.cluster.local/share#pvc-4729891a-f57e-4982-9c60-e9884af1be2f -// smb-server.default.svc.cluster.local/share#subdir#pvc-4729891a-f57e-4982-9c60-e9884af1be2f +// +// smb-server.default.svc.cluster.local/share#pvc-4729891a-f57e-4982-9c60-e9884af1be2f +// smb-server.default.svc.cluster.local/share#subdir#pvc-4729891a-f57e-4982-9c60-e9884af1be2f func getSmbVolFromID(id string) (*smbVolume, error) { segments := strings.Split(id, separator) if len(segments) < 2 { diff --git a/pkg/smb/fake_mounter.go b/pkg/smb/fake_mounter.go index c888a1fce46..6dc41c53a11 100644 --- a/pkg/smb/fake_mounter.go +++ b/pkg/smb/fake_mounter.go @@ -52,7 +52,7 @@ func (f *fakeMounter) MountSensitive(source string, target string, fstype string return nil } -//IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint. +// IsLikelyNotMountPoint overrides mount.FakeMounter.IsLikelyNotMountPoint. func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) { if strings.Contains(file, "error_is_likely") { return false, fmt.Errorf("fake IsLikelyNotMountPoint: fake error")