This repository was archived by the owner on Aug 14, 2021. It is now read-only.
forked from kubernetes-retired/external-storage
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support fstype other then ext4 (#38)
This commit will extend the provisioner to support other filesystem i.e. XFS, ext3 etc. Ext4 will be the default fstype for openebs volumes. But can be changed via storageclass parameter key/value for example "openebs.io/fstype : xfs" --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: openebs-percona provisioner: openebs.io/provisioner-iscsi parameters: openebs.io/storage-pool: "default" openebs.io/jiva-replica-count: "1" openebs.io/volume-monitor: "true" openebs.io/capacity: 5G openebs.io/fstype: "xfs" --- Also this PR adds OPENEBS_VALID_FSTYPE ENV config parameter OPENEBS_VALID_FSTYPE can be exported as supported fstype for openebs volume. This can be set as ENV in openebs-provisioner pod deployment.for example: OPENEBS_VALID_FSTYPE="ext3,btrfs,zfs" Signed-off-by: prateekpandey14 <[email protected]>
- Loading branch information
1 parent
4605b22
commit f95698c
Showing
3 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestParseClassParameters(t *testing.T) { | ||
cases := map[string]struct { | ||
cfgs map[string]string | ||
expectErr error | ||
expectfstype string | ||
}{ | ||
"Dafault fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": ""}, | ||
expectErr: nil, | ||
expectfstype: "ext4", | ||
}, | ||
"ext4 fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": "ext4"}, | ||
expectErr: nil, | ||
expectfstype: "ext4", | ||
}, | ||
"xfs fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": "xfs"}, | ||
expectErr: nil, | ||
expectfstype: "xfs", | ||
}, | ||
"Invalid fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": "nfs"}, | ||
expectErr: fmt.Errorf("Filesystem nfs is not supported"), | ||
expectfstype: "", | ||
}, | ||
} | ||
|
||
for name, tc := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
fstype, err := parseClassParameters(tc.cfgs) | ||
if !reflect.DeepEqual(err, tc.expectErr) { | ||
t.Errorf("Expected %v, got %v", tc.expectErr, err) | ||
} | ||
if !reflect.DeepEqual(fstype, tc.expectfstype) { | ||
t.Errorf("Expected %v, got %v", tc.expectfstype, fstype) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestParseClassENVParameters(t *testing.T) { | ||
cases := map[string]struct { | ||
cfgs map[string]string | ||
expectErr error | ||
expectfstype string | ||
}{ | ||
"Dafault fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": ""}, | ||
expectErr: nil, | ||
expectfstype: "ext4", | ||
}, | ||
"ext4 fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": "ext4"}, | ||
expectErr: nil, | ||
expectfstype: "ext4", | ||
}, | ||
"ENV fstype nfs": { | ||
cfgs: map[string]string{"openebs.io/fstype": "nfs"}, | ||
expectErr: nil, | ||
expectfstype: "nfs", | ||
}, | ||
"Invalid fstype": { | ||
cfgs: map[string]string{"openebs.io/fstype": "abcd"}, | ||
expectErr: fmt.Errorf("Filesystem abcd is not supported"), | ||
expectfstype: "", | ||
}, | ||
"ENV fstype btrfs": { | ||
cfgs: map[string]string{"openebs.io/fstype": "btrfs"}, | ||
expectErr: nil, | ||
expectfstype: "btrfs", | ||
}, | ||
"ENV fstype zfs": { | ||
cfgs: map[string]string{"openebs.io/fstype": "zfs"}, | ||
expectErr: nil, | ||
expectfstype: "zfs", | ||
}, | ||
} | ||
|
||
for name, tc := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
|
||
os.Setenv("OPENEBS_VALID_FSTYPE", "nfs,btrfs,zfs") | ||
defer os.Unsetenv("OPENEBS_VALID_FSTYPE") | ||
|
||
fstype, err := parseClassParameters(tc.cfgs) | ||
if !reflect.DeepEqual(err, tc.expectErr) { | ||
t.Errorf("Expected %v, got %v", tc.expectErr, err) | ||
} | ||
if !reflect.DeepEqual(fstype, tc.expectfstype) { | ||
t.Errorf("Expected %v, got %v", tc.expectfstype, fstype) | ||
} | ||
}) | ||
} | ||
} |