Skip to content

Commit

Permalink
Merge pull request #15 from RomanBednar/cherry-fstype-param
Browse files Browse the repository at this point in the history
Bug 2080449: UPSTREAM: 1023: add new option to allow VHD feature opt-out
  • Loading branch information
openshift-merge-robot committed Jun 15, 2022
2 parents 57adb71 + b3645b3 commit 67c3831
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 @@ -174,6 +174,7 @@ type DriverOptions struct {
UserAgentSuffix string
AllowEmptyCloudConfig bool
AllowInlineVolumeKeyAccessWithIdentity bool
EnableVHDDiskFeature bool
EnableGetVolumeStats bool
MountPermissions uint64
}
Expand All @@ -188,6 +189,7 @@ type Driver struct {
userAgentSuffix string
allowEmptyCloudConfig bool
allowInlineVolumeKeyAccessWithIdentity bool
enableVHDDiskFeature bool
enableGetVolumeStats bool
mountPermissions uint64
fileClient *azureFileClient
Expand Down Expand Up @@ -226,6 +228,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.volLockMap = newLockMap()
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 @@ -220,6 +220,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 @@ -231,7 +231,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 @@ -308,7 +314,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 @@ -759,7 +771,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 @@ -50,6 +50,7 @@ var (
enableGetVolumeStats = flag.Bool("enable-get-volume-stats", true, "allow GET_VOLUME_STATS on agent node")
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")
enableVHDDiskFeature = flag.Bool("enable-vhd", true, "enable VHD disk feature (experimental)")
)

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

0 comments on commit 67c3831

Please sign in to comment.