Skip to content

Commit

Permalink
restore v1beta
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliy-leschenko committed Jul 31, 2022
1 parent 1c7e99b commit b9ed005
Showing 1 changed file with 2 additions and 42 deletions.
44 changes: 2 additions & 42 deletions pkg/mounter/safe_mounter_v1beta_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ type csiProxyMounterV1Beta struct {
}

func (mounter *csiProxyMounterV1Beta) SMBMount(source, target, fsType string, mountOptions, sensitiveMountOptions []string) error {
mutex.Lock()
defer mutex.Unlock()

klog.V(4).Infof("SMBMount: remote path: %s. local path: %s", source, target)

if len(mountOptions) == 0 || len(sensitiveMountOptions) == 0 {
Expand Down Expand Up @@ -93,50 +90,13 @@ func (mounter *csiProxyMounterV1Beta) SMBMount(source, target, fsType string, mo
return fmt.Errorf("smb mapping failed with error: %v", err)
}
klog.V(2).Infof("mount %s on %s successfully", source, normalizedTarget)

mappingPath := normalizeMappingPath(source)
err = incementMappingPathCount(mappingPath, source)
if err != nil {
klog.Warningf("failed incementMappingPathCount %v", err)
}

return nil
}

func (mounter *csiProxyMounterV1Beta) SMBUnmount(target string) error {
mutex.Lock()
defer mutex.Unlock()

klog.V(4).Infof("SMBUnmount: local path: %s", target)

if remotePath, err := os.Readlink(target); err != nil {
klog.Warningf("SMBUnmount: can't get remote path: %v", err)
} else {
klog.V(4).Infof("SMBUnmount: remote path: %s", remotePath)

mappingPath := normalizeMappingPath(remotePath)
klog.V(4).Infof("SMBUnmount: mapping path: %s", mappingPath)

if err := decrementMappingPathCount(mappingPath, remotePath); err != nil {
klog.Warningf("SMBUnmount: failed decrementMappingPathCount %v", err)
} else {
count := getMappingPathCount(mappingPath)
if count == 0 {
smbUnmountRequest := &smb.RemoveSmbGlobalMappingRequest{
RemotePath: remotePath,
}
klog.V(2).Infof("begin to unmount %s on %s", remotePath, target)
if _, err := mounter.SMBClient.RemoveSmbGlobalMapping(context.Background(), smbUnmountRequest); err != nil {
klog.Warningf("smb unmapping failed with error: %v", err)
} else {
klog.V(2).Infof("unmount %s on %s successfully", remotePath, target)
}
} else {
klog.Infof("SMBUnmount: found %f links to %s", count, mappingPath)
}
}
}

// TODO: We need to remove the SMB mapping. The change to remove the
// directory brings the CSI code in parity with the in-tree.
return mounter.Rmdir(target)
}

Expand Down

0 comments on commit b9ed005

Please sign in to comment.