Skip to content

Commit

Permalink
Merge pull request #400 from humblec/defaultfstype
Browse files Browse the repository at this point in the history
Make fstype configurable in external provisioner
  • Loading branch information
k8s-ci-robot authored Jun 17, 2020
2 parents 62e7df3 + 4515622 commit c1de898
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 38 deletions.
20 changes: 10 additions & 10 deletions cmd/csi-provisioner/csi-provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,25 @@ import (
"strings"
"time"

flag "github.com/spf13/pflag"

"github.com/kubernetes-csi/csi-lib-utils/deprecatedflags"
"github.com/kubernetes-csi/csi-lib-utils/leaderelection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
ctrl "github.com/kubernetes-csi/external-provisioner/pkg/controller"
snapclientset "github.com/kubernetes-csi/external-snapshotter/pkg/client/clientset/versioned"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v5/controller"

flag "github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog"

utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
v1 "k8s.io/client-go/listers/core/v1"
storagelistersv1 "k8s.io/client-go/listers/storage/v1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/workqueue"
utilflag "k8s.io/component-base/cli/flag"
csitrans "k8s.io/csi-translation-lib"
"k8s.io/klog"
"sigs.k8s.io/sig-storage-lib-external-provisioner/v5/controller"
)

var (
Expand All @@ -74,6 +71,8 @@ var (
metricsAddress = flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled.")
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")

defaultFSType = flag.String("default-fstype", "", "The default filesystem type of the volume to provision when fstype is unspecified in the StorageClass. If the default is not set and fstype is unset in the StorageClass, then no fstype will be set")

featureGates map[string]bool
provisionController *controller.ProvisionController
version = "unknown"
Expand Down Expand Up @@ -240,6 +239,7 @@ func main() {
claimLister,
vaLister,
*extraCreateMetadata,
*defaultFSType,
)

provisionController = controller.NewProvisionController(
Expand Down
9 changes: 5 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ const (
backoffFactor = 1.2
backoffSteps = 10

defaultFSType = "ext4"

snapshotKind = "VolumeSnapshot"
snapshotAPIGroup = snapapi.GroupName // "snapshot.storage.k8s.io"
pvcKind = "PersistentVolumeClaim" // Native types don't require an API group
Expand Down Expand Up @@ -211,6 +209,7 @@ type csiProvisioner struct {
timeout time.Duration
identity string
volumeNamePrefix string
defaultFSType string
volumeNameUUIDLength int
config *rest.Config
driverName string
Expand Down Expand Up @@ -292,6 +291,7 @@ func NewCSIProvisioner(client kubernetes.Interface,
claimLister corelisters.PersistentVolumeClaimLister,
vaLister storagelistersv1.VolumeAttachmentLister,
extraCreateMetadata bool,
defaultFSType string,
) controller.Provisioner {
broadcaster := record.NewBroadcaster()
broadcaster.StartLogging(klog.Infof)
Expand All @@ -307,6 +307,7 @@ func NewCSIProvisioner(client kubernetes.Interface,
timeout: connectionTimeout,
identity: identity,
volumeNamePrefix: volumeNamePrefix,
defaultFSType: defaultFSType,
volumeNameUUIDLength: volumeNameUUIDLength,
driverName: driverName,
pluginCapabilities: pluginCapabilities,
Expand Down Expand Up @@ -518,8 +519,8 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
if fsTypesFound > 1 {
return nil, controller.ProvisioningFinished, fmt.Errorf("fstype specified in parameters with both \"fstype\" and \"%s\" keys", prefixedFsTypeKey)
}
if len(fsType) == 0 {
fsType = defaultFSType
if fsType == "" && p.defaultFSType != "" {
fsType = p.defaultFSType
}

capacity := options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
Expand Down
Loading

0 comments on commit c1de898

Please sign in to comment.