Skip to content

Commit

Permalink
feat(zfs-localpv): add option for choosing between refquota and quota…
Browse files Browse the repository at this point in the history
… on storageclass

Signed-off-by: cina_pm <[email protected]>
  • Loading branch information
cinapm committed Jul 11, 2024
1 parent 1b0b77e commit a87da86
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 4 deletions.
8 changes: 8 additions & 0 deletions deploy/yamls/zfsrestore-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ spec:
been provisioned.
minLength: 1
type: string
quotaType:
description: 'quotaType determines whether the dataset volume quota
type is of type "quota" or "refquota". QuotaType can not be modified
once volume has been provisioned. Default Value: quota.'
enum:
- quota
- refquota
type: string
recordsize:
description: 'Specifies a suggested block size for files in the file
system. The size specified must be a power of two greater than or
Expand Down
8 changes: 8 additions & 0 deletions deploy/yamls/zfssnapshot-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ spec:
been provisioned.
minLength: 1
type: string
quotaType:
description: 'quotaType determines whether the dataset volume quota
type is of type "quota" or "refquota". QuotaType can not be modified
once volume has been provisioned. Default Value: quota.'
enum:
- quota
- refquota
type: string
recordsize:
description: 'Specifies a suggested block size for files in the file
system. The size specified must be a power of two greater than or
Expand Down
8 changes: 8 additions & 0 deletions deploy/yamls/zfsvolume-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ spec:
been provisioned.
minLength: 1
type: string
quotaType:
description: 'quotaType determines whether the dataset volume quota
type is of type "quota" or "refquota". QuotaType can not be modified
once volume has been provisioned. Default Value: quota.'
enum:
- quota
- refquota
type: string
recordsize:
description: 'Specifies a suggested block size for files in the file
system. The size specified must be a power of two greater than or
Expand Down
24 changes: 24 additions & 0 deletions deploy/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ spec:
been provisioned.
minLength: 1
type: string
quotaType:
description: 'quotaType determines whether the dataset volume quota
type is of type "quota" or "refquota". QuotaType can not be modified
once volume has been provisioned. Default Value: quota.'
enum:
- quota
- refquota
type: string
recordsize:
description: 'Specifies a suggested block size for files in the file
system. The size specified must be a power of two greater than or
Expand Down Expand Up @@ -602,6 +610,14 @@ spec:
been provisioned.
minLength: 1
type: string
quotaType:
description: 'quotaType determines whether the dataset volume quota
type is of type "quota" or "refquota". QuotaType can not be modified
once volume has been provisioned. Default Value: quota.'
enum:
- quota
- refquota
type: string
recordsize:
description: 'Specifies a suggested block size for files in the file
system. The size specified must be a power of two greater than or
Expand Down Expand Up @@ -1132,6 +1148,14 @@ spec:
been provisioned.
minLength: 1
type: string
quotaType:
description: 'quotaType determines whether the dataset volume quota
type is of type "quota" or "refquota". QuotaType can not be modified
once volume has been provisioned. Default Value: quota.'
enum:
- quota
- refquota
type: string
recordsize:
description: 'Specifies a suggested block size for files in the file
system. The size specified must be a power of two greater than or
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/openebs.io/zfs/v1/zfsvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ type VolumeInfo struct {
// +kubebuilder:validation:Enum=ZVOL;DATASET
VolumeType string `json:"volumeType"`

// quotaType determines whether the dataset volume quota type is of type "quota" or "refquota".
// QuotaType can not be modified once volume has been provisioned.
// +kubebuilder:validation:Enum=quota;refquota
// Default Value: quota.
QuotaType string `json:"quotaType,omitempty"`

// FsType specifies filesystem type for the zfs volume/dataset.
// If FsType is provided as "zfs", then the driver will create a
// ZFS dataset, formatting is not required as underlying filesystem is ZFS anyway.
Expand Down
10 changes: 10 additions & 0 deletions pkg/builder/volbuilder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ func (b *Builder) WithFsType(fstype string) *Builder {
return b
}

// WithQuotaType sets quota type for dataset volume
func (b *Builder) WithQuotaType(quotatype string) *Builder {
if quotatype != "" {
b.volume.Object.Spec.QuotaType = quotatype
} else {
b.volume.Object.Spec.QuotaType = "quota"
}
return b
}

// WithShared sets where filesystem is shared or not
func (b *Builder) WithShared(shared string) *Builder {
b.volume.Object.Spec.Shared = shared
Expand Down
2 changes: 2 additions & 0 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func CreateZFSVolume(ctx context.Context, req *csi.CreateVolumeRequest) (string,
schld := parameters["scheduler"]
fstype := parameters["fstype"]
shared := parameters["shared"]
qoutatype := parameters["qoutatype"]

vtype := zfs.GetVolumeType(fstype)

Expand Down Expand Up @@ -295,6 +296,7 @@ func CreateZFSVolume(ctx context.Context, req *csi.CreateVolumeRequest) (string,
WithVolumeType(vtype).
WithVolumeStatus(zfs.ZFSStatusPending).
WithFsType(fstype).
WithQuotaType(qoutatype).
WithShared(shared).
WithCompression(compression).Build()

Expand Down
8 changes: 4 additions & 4 deletions pkg/zfs/zfs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func buildCloneCreateArgs(vol *apis.ZFSVolume) []string {

if vol.Spec.VolumeType == VolTypeDataset {
if len(vol.Spec.Capacity) != 0 {
quotaProperty := "quota=" + vol.Spec.Capacity
quotaProperty := vol.Spec.QuotaType + "=" + vol.Spec.Capacity
ZFSVolArg = append(ZFSVolArg, "-o", quotaProperty)
}
if len(vol.Spec.RecordSize) != 0 {
Expand Down Expand Up @@ -216,7 +216,7 @@ func buildDatasetCreateArgs(vol *apis.ZFSVolume) []string {
ZFSVolArg = append(ZFSVolArg, ZFSCreateArg)

if len(vol.Spec.Capacity) != 0 {
quotaProperty := "quota=" + vol.Spec.Capacity
quotaProperty := vol.Spec.QuotaType + "=" + vol.Spec.Capacity
ZFSVolArg = append(ZFSVolArg, "-o", quotaProperty)
}
if len(vol.Spec.RecordSize) != 0 {
Expand Down Expand Up @@ -292,7 +292,7 @@ func buildVolumeResizeArgs(vol *apis.ZFSVolume) []string {
ZFSVolArg = append(ZFSVolArg, ZFSSetArg)

if vol.Spec.VolumeType == VolTypeDataset {
quotaProperty := "quota=" + vol.Spec.Capacity
quotaProperty := vol.Spec.QuotaType + "=" + vol.Spec.Capacity
ZFSVolArg = append(ZFSVolArg, quotaProperty)
} else {
volsizeProperty := "volsize=" + vol.Spec.Capacity
Expand Down Expand Up @@ -350,7 +350,7 @@ func buildVolumeRestoreArgs(rstr *apis.ZFSRestore) ([]string, error) {

if rstr.VolSpec.VolumeType == VolTypeDataset {
if len(rstr.VolSpec.Capacity) != 0 {
ZFSRecvParam += " -o quota=" + rstr.VolSpec.Capacity
ZFSRecvParam += " -o " + rstr.VolSpec.QuotaType + "=" + rstr.VolSpec.Capacity
}
if len(rstr.VolSpec.RecordSize) != 0 {
ZFSRecvParam += " -o recordsize=" + rstr.VolSpec.RecordSize
Expand Down

0 comments on commit a87da86

Please sign in to comment.