Allow configuring mounter via storageclass parameter

This commit is contained in:
Cyrill Troxler 2018-07-29 10:00:53 +02:00
parent 4b82c93978
commit c7abe28ade
7 changed files with 18 additions and 17 deletions

View file

@ -50,6 +50,8 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
capacityBytes := int64(req.GetCapacityRange().GetRequiredBytes())
params := req.GetParameters()
mounter := params[mounterTypeKey]
glog.V(5).Infof("Got a request to create bucket %s", volumeID)
@ -77,6 +79,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
b := &bucket{
Name: volumeID,
Mounter: mounter,
CapacityBytes: capacityBytes,
FSPath: fsPrefix,
}

View file

@ -22,11 +22,17 @@ const (
goofysMounterType = "goofys"
s3qlMounterType = "s3ql"
s3backerMounterType = "s3backer"
mounterTypeKey = "mounter"
)
// newMounter returns a new mounter depending on the mounterType parameter
func newMounter(bucket *bucket, cfg *Config) (Mounter, error) {
switch cfg.Mounter {
mounter := bucket.Mounter
// Fall back to mounterType in cfg
if len(bucket.Mounter) == 0 {
mounter = cfg.Mounter
}
switch mounter {
case s3fsMounterType:
return newS3fsMounter(bucket, cfg)
@ -39,8 +45,10 @@ func newMounter(bucket *bucket, cfg *Config) (Mounter, error) {
case s3backerMounterType:
return newS3backerMounter(bucket, cfg)
default:
// default to s3backer
return newS3backerMounter(bucket, cfg)
}
return nil, fmt.Errorf("Error mounting bucket %s, invalid mounter specified: %s", bucket.Name, cfg.Mounter)
}
func fuseMount(path string, command string, args []string) error {

View file

@ -23,6 +23,7 @@ type s3Client struct {
type bucket struct {
Name string
Mounter string
FSPath string
CapacityBytes int64
}