Skip to content

Commit

Permalink
Merge pull request #128 from manueltellez/master
Browse files Browse the repository at this point in the history
Make GPT the new partition style for volumes. Normalize windows paths in SMB apis to support linux style paths in source.
  • Loading branch information
k8s-ci-robot authored Apr 30, 2021
2 parents eb09396 + 2437803 commit 41e1a53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion integrationtests/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func diskInit(t *testing.T, vhdxPath, mountPath, testPluginPath string) string {
var cmd, out string
var err error
const initialSize = 5 * 1024 * 1024 * 1024
const partitionStyle = "MBR"
const partitionStyle = "GPT"

cmd = fmt.Sprintf("mkdir %s", mountPath)
if out, err = runPowershellCmd(cmd); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/os/disk/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (APIImplementor) IsDiskInitialized(diskID string) (bool, error) {
}

func (APIImplementor) InitializeDisk(diskID string) error {
cmd := fmt.Sprintf("Initialize-Disk -Number %s -PartitionStyle MBR", diskID)
cmd := fmt.Sprintf("Initialize-Disk -Number %s -PartitionStyle GPT", diskID)
out, err := exec.Command("powershell", "/c", cmd).CombinedOutput()
if err != nil {
return fmt.Errorf("error initializing disk %s: %v, %v", diskID, out, err)
Expand Down
11 changes: 8 additions & 3 deletions internal/server/smb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package smb
import (
"context"
"fmt"

"github.com/kubernetes-csi/csi-proxy/client/apiversion"
fsserver "github.com/kubernetes-csi/csi-proxy/internal/server/filesystem"
"github.com/kubernetes-csi/csi-proxy/internal/server/smb/internal"
"k8s.io/klog/v2"
"strings"
)

type Server struct {
Expand All @@ -22,6 +22,11 @@ type API interface {
RemoveSmbGlobalMapping(remotePath string) error
}

func normalizeWindowsPath(path string) string {
normalizedPath := strings.Replace(path, "/", "\\", -1)
return normalizedPath
}

func NewServer(hostAPI API, fsServer *fsserver.Server) (*Server, error) {
return &Server{
hostAPI: hostAPI,
Expand All @@ -32,7 +37,7 @@ func NewServer(hostAPI API, fsServer *fsserver.Server) (*Server, error) {
func (s *Server) NewSmbGlobalMapping(context context.Context, request *internal.NewSmbGlobalMappingRequest, version apiversion.Version) (*internal.NewSmbGlobalMappingResponse, error) {
klog.V(4).Infof("calling NewSmbGlobalMapping with remote path %q", request.RemotePath)
response := &internal.NewSmbGlobalMappingResponse{}
remotePath := request.RemotePath
remotePath := normalizeWindowsPath(request.RemotePath)
localPath := request.LocalPath

if remotePath == "" {
Expand Down Expand Up @@ -90,7 +95,7 @@ func (s *Server) NewSmbGlobalMapping(context context.Context, request *internal.
func (s *Server) RemoveSmbGlobalMapping(context context.Context, request *internal.RemoveSmbGlobalMappingRequest, version apiversion.Version) (*internal.RemoveSmbGlobalMappingResponse, error) {
klog.V(4).Infof("calling RemoveSmbGlobalMapping with remote path %q", request.RemotePath)
response := &internal.RemoveSmbGlobalMappingResponse{}
remotePath := request.RemotePath
remotePath := normalizeWindowsPath(request.RemotePath)

if remotePath == "" {
klog.Errorf("remote path is empty")
Expand Down

0 comments on commit 41e1a53

Please sign in to comment.