Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GPT the new partition style for volumes. Normalize windows paths in SMB apis to support linux style paths in source. #128

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 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