From 784697abe32bf709a5834763e09372ffede7d258 Mon Sep 17 00:00:00 2001 From: Nobi Date: Sun, 25 Sep 2022 20:05:06 +0000 Subject: [PATCH] Support config device type Signed-off-by: Nobi --- cmd/provisioner-localpv/app/config.go | 4 ++++ cmd/provisioner-localpv/app/helper_blockdevice.go | 11 ++++++++--- .../app/provisioner_blockdevice.go | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/provisioner-localpv/app/config.go b/cmd/provisioner-localpv/app/config.go index 58803feb..a7c920da 100644 --- a/cmd/provisioner-localpv/app/config.go +++ b/cmd/provisioner-localpv/app/config.go @@ -41,6 +41,10 @@ const ( // can be configured via the StorageClass annotations. KeyPVBasePath = "BasePath" + //KeyPVDeviceType defines the type of device like + // sparse, disk, partition, lvm, crypt + KeyPVDeviceType = "DeviceType" + //KeyPVFSType defines filesystem type to be used with devices // and can be configured via the StorageClass annotations. KeyPVFSType = "FSType" diff --git a/cmd/provisioner-localpv/app/helper_blockdevice.go b/cmd/provisioner-localpv/app/helper_blockdevice.go index eb2cf653..1eeee42f 100644 --- a/cmd/provisioner-localpv/app/helper_blockdevice.go +++ b/cmd/provisioner-localpv/app/helper_blockdevice.go @@ -51,9 +51,10 @@ type HelperBlockDeviceOptions struct { //nodeAffinityLabels represents the labels of the node where pod should be launched. nodeAffinityLabels map[string]string - capacity string - // deviceType string - bdcName string + capacity string + deviceType string + bdcName string + // volumeMode of PVC volumeMode corev1.PersistentVolumeMode @@ -126,6 +127,10 @@ func (p *Provisioner) createBlockDeviceClaim(ctx context.Context, blkDevOpts *He WithFinalizer(LocalPVFinalizer). WithBlockVolumeMode(blkDevOpts.volumeMode) + if blkDevOpts.deviceType != "" { + bdcObjBuilder.WithDeviceType(blkDevOpts.deviceType) + } + // if block device selectors are present, set it on the BDC if blkDevOpts.bdSelectors != nil { bdcObjBuilder.WithSelector(blkDevOpts.bdSelectors) diff --git a/cmd/provisioner-localpv/app/provisioner_blockdevice.go b/cmd/provisioner-localpv/app/provisioner_blockdevice.go index 8c4969db..f7f06b0b 100644 --- a/cmd/provisioner-localpv/app/provisioner_blockdevice.go +++ b/cmd/provisioner-localpv/app/provisioner_blockdevice.go @@ -78,6 +78,7 @@ func (p *Provisioner) ProvisionBlockDevice(ctx context.Context, opts pvControlle name: name, nodeAffinityLabels: nodeAffinityLabels, capacity: capacity.String(), + deviceType: volumeConfig.getValue(KeyPVDeviceType), volumeMode: *opts.PVC.Spec.VolumeMode, bdSelectors: volumeConfig.GetBlockDeviceSelectors(), }