Skip to content

Commit

Permalink
Merge pull request #1023 from RomanBednar/fstype-param
Browse files Browse the repository at this point in the history
add new option to allow VHD feature opt-out
  • Loading branch information
andyzhangx committed Jun 7, 2022
2 parents e26287d + 774f13b commit b947067
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pkg/azurefile/azurefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ type DriverOptions struct {
UserAgentSuffix string
AllowEmptyCloudConfig bool
AllowInlineVolumeKeyAccessWithIdentity bool
EnableVHDDiskFeature bool
EnableGetVolumeStats bool
MountPermissions uint64
FSGroupChangePolicy string
Expand All @@ -200,6 +201,7 @@ type Driver struct {
fsGroupChangePolicy string
allowEmptyCloudConfig bool
allowInlineVolumeKeyAccessWithIdentity bool
enableVHDDiskFeature bool
enableGetVolumeStats bool
mountPermissions uint64
fileClient *azureFileClient
Expand Down Expand Up @@ -238,6 +240,7 @@ func NewDriver(options *DriverOptions) *Driver {
driver.userAgentSuffix = options.UserAgentSuffix
driver.allowEmptyCloudConfig = options.AllowEmptyCloudConfig
driver.allowInlineVolumeKeyAccessWithIdentity = options.AllowInlineVolumeKeyAccessWithIdentity
driver.enableVHDDiskFeature = options.EnableVHDDiskFeature
driver.enableGetVolumeStats = options.EnableGetVolumeStats
driver.mountPermissions = options.MountPermissions
driver.fsGroupChangePolicy = options.FSGroupChangePolicy
Expand Down
8 changes: 8 additions & 0 deletions pkg/azurefile/azurefile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ func NewFakeDriver() *Driver {
return driver
}

func NewFakeDriverCustomOptions(opts DriverOptions) *Driver {
driverOptions := opts
driver := NewDriver(&driverOptions)
driver.Name = fakeDriverName
driver.Version = vendorVersion
return driver
}

func TestNewFakeDriver(t *testing.T) {
driverOptions := DriverOptions{
NodeID: fakeNodeID,
Expand Down
4 changes: 4 additions & 0 deletions pkg/azurefile/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
}
}

if !d.enableVHDDiskFeature && fsType != "" {
return nil, status.Errorf(codes.InvalidArgument, "fsType storage class parameter enables experimental VDH disk feature which is currently disabled, use --enable-vhd driver option to enable it")
}

if !isSupportedFsType(fsType) {
return nil, status.Errorf(codes.InvalidArgument, "fsType(%s) is not supported, supported fsType list: %v", fsType, supportedFsTypeList)
}
Expand Down
24 changes: 21 additions & 3 deletions pkg/azurefile/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ func TestCreateVolume(t *testing.T) {
}

ctx := context.Background()
d := NewFakeDriver()

driverOptions := DriverOptions{
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
EnableVHDDiskFeature: true,
}
d := NewFakeDriverCustomOptions(driverOptions)

d.AddControllerServiceCapabilities(
[]csi.ControllerServiceCapability_RPC_Type{
Expand Down Expand Up @@ -272,7 +278,13 @@ func TestCreateVolume(t *testing.T) {
}

ctx := context.Background()
d := NewFakeDriver()

driverOptions := DriverOptions{
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
EnableVHDDiskFeature: true,
}
d := NewFakeDriverCustomOptions(driverOptions)

d.AddControllerServiceCapabilities(
[]csi.ControllerServiceCapability_RPC_Type{
Expand Down Expand Up @@ -765,7 +777,13 @@ func TestCreateVolume(t *testing.T) {
Parameters: allParam,
}

d := NewFakeDriver()
driverOptions := DriverOptions{
NodeID: fakeNodeID,
DriverName: DefaultDriverName,
EnableVHDDiskFeature: true,
}
d := NewFakeDriverCustomOptions(driverOptions)

d.cloud = &azure.Cloud{}
d.cloud.KubeClient = fake.NewSimpleClientset()

Expand Down
2 changes: 2 additions & 0 deletions pkg/azurefileplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var (
mountPermissions = flag.Uint64("mount-permissions", 0777, "mounted folder permissions")
allowInlineVolumeKeyAccessWithIdentity = flag.Bool("allow-inline-volume-key-access-with-identity", false, "allow accessing storage account key using cluster identity for inline volume")
fsGroupChangePolicy = flag.String("fsgroup-change-policy", "", "indicates how the volume's ownership will be changed by the driver, OnRootMismatch is the default value")
enableVHDDiskFeature = flag.Bool("enable-vhd", true, "enable VHD disk feature (experimental)")
)

func main() {
Expand Down Expand Up @@ -87,6 +88,7 @@ func handle() {
MountPermissions: *mountPermissions,
AllowInlineVolumeKeyAccessWithIdentity: *allowInlineVolumeKeyAccessWithIdentity,
FSGroupChangePolicy: *fsGroupChangePolicy,
EnableVHDDiskFeature: *enableVHDDiskFeature,
}
driver := azurefile.NewDriver(&driverOptions)
if driver == nil {
Expand Down

0 comments on commit b947067

Please sign in to comment.