From 6bf1ce6367b91959aa33ccf30fc2aa447796d3dc Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Tue, 27 Oct 2020 16:52:30 -0700 Subject: [PATCH] Add fstype for Windows Add defensive check for Windows. GCE PD CSI driver only support ntfs for Windows. If other fstype is passed, return error. --- pkg/gce-pd-csi-driver/utils_windows.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/gce-pd-csi-driver/utils_windows.go b/pkg/gce-pd-csi-driver/utils_windows.go index 9e8d79e82..15a91c65a 100644 --- a/pkg/gce-pd-csi-driver/utils_windows.go +++ b/pkg/gce-pd-csi-driver/utils_windows.go @@ -17,6 +17,7 @@ package gceGCEDriver import ( "fmt" + "strings" "k8s.io/utils/mount" "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common" @@ -24,6 +25,9 @@ import ( ) func formatAndMount(source, target, fstype string, options []string, m *mount.SafeFormatAndMount) error { + if !strings.EqualFold(fstype, defaultWindowsFsType) { + return fmt.Errorf("GCE PD CSI driver can only supports %s file system, it does not support %s", defaultWindowsFsType, fstype) + } proxy, ok := m.Interface.(*mounter.CSIProxyMounter) if !ok { return fmt.Errorf("could not cast to csi proxy class")