Skip to content

Commit

Permalink
Add mount options
Browse files Browse the repository at this point in the history
Copy mount options from the storage class to the PV spec.
  • Loading branch information
bswartz committed Oct 11, 2018
1 parent 7be433e commit be14b93
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ const (
var _ controller.Provisioner = &csiProvisioner{}

var (
accessType = &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
}
// Each provisioner have a identify string to distinguish with others. This
// identify string will be added in PV annoations under this key.
provisionerIDKey = "storage.kubernetes.io/csiProvisionerIdentity"
Expand Down Expand Up @@ -361,9 +358,27 @@ func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
return nil, err
}

fsType := ""
for k, v := range options.Parameters {
switch strings.ToLower(k) {
case "fstype":
fsType = v
}
}
if len(fsType) == 0 {
fsType = defaultFSType
}

capacity := options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
volSizeBytes := capacity.Value()

accessType := &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{
FsType: fsType,
MountFlags: options.MountOptions,
},
}

// Get access mode
volumeCaps := make([]*csi.VolumeCapability, 0)
for _, cap := range options.PVC.Spec.AccessModes {
Expand Down Expand Up @@ -502,24 +517,14 @@ func (p *csiProvisioner) Provision(options controller.VolumeOptions) (*v1.Persis
return nil, capErr
}

fsType := ""
for k, v := range options.Parameters {
switch strings.ToLower(k) {
case "fstype":
fsType = v
}
}
if len(fsType) == 0 {
fsType = defaultFSType
}

pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: pvName,
},
Spec: v1.PersistentVolumeSpec{
PersistentVolumeReclaimPolicy: options.PersistentVolumeReclaimPolicy,
AccessModes: options.PVC.Spec.AccessModes,
MountOptions: options.MountOptions,
Capacity: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): bytesToGiQuantity(respCap),
},
Expand Down

0 comments on commit be14b93

Please sign in to comment.