Skip to content

Commit

Permalink
provide option to set pluginpath for cephfs
Browse files Browse the repository at this point in the history
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Jul 4, 2019
1 parent 5cf0599 commit 9b24524
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
10 changes: 6 additions & 4 deletions cmd/cephcsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"flag"
"os"
"path"
"path/filepath"
"strings"

"github.com/ceph/ceph-csi/pkg/cephfs"
Expand Down Expand Up @@ -52,6 +53,8 @@ var (
volumeMounter = flag.String("volumemounter", "", "default volume mounter (possible options are 'kernel', 'fuse')")
mountCacheDir = flag.String("mountcachedir", "", "mount info cache save dir")
metadataStorage = flag.String("metadatastorage", "", "metadata persistence method [node|k8s_configmap]")

pluginFoler = flag.String("pluginpath", "/var/lib/kubelet/plugins/", "the location of cephcsi plugin")
)

func init() {
Expand Down Expand Up @@ -108,21 +111,20 @@ func main() {
klog.Infof("Starting driver type: %v with name: %v", driverType, dname)
switch driverType {
case rbdType:
rbd.PluginFolder += dname
driver := rbd.NewDriver()
driver.Run(dname, *nodeID, *endpoint, *instanceID, *containerized)

case cephfsType:
cephfs.PluginFolder += dname
*pluginFoler = filepath.Join(*pluginFoler, dname)
if *metadataStorage != "" {
cp, err = util.CreatePersistanceStorage(
cephfs.PluginFolder, *metadataStorage, dname)
*pluginFoler, *metadataStorage, *pluginFoler)
if err != nil {
os.Exit(1)
}
}
driver := cephfs.NewDriver()
driver.Run(dname, *nodeID, *endpoint, *volumeMounter, *mountCacheDir, *instanceID, cp)
driver.Run(dname, *nodeID, *endpoint, *volumeMounter, *mountCacheDir, *instanceID, *pluginFoler, cp)

default:
klog.Fatalln("invalid volume type", vtype) // calls exit
Expand Down
5 changes: 3 additions & 2 deletions pkg/cephfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
)

// PluginFolder defines the location of ceph plugin
var PluginFolder = "/var/lib/kubelet/plugins/"
var PluginFolder = ""

// Driver contains the default identity,node and controller struct
type Driver struct {
Expand Down Expand Up @@ -93,10 +93,11 @@ func NewNodeServer(d *csicommon.CSIDriver) *NodeServer {

// Run start a non-blocking grpc controller,node and identityserver for
// ceph CSI driver which can serve multiple parallel requests
func (fs *Driver) Run(driverName, nodeID, endpoint, volumeMounter, mountCacheDir, instanceID string, cachePersister util.CachePersister) {
func (fs *Driver) Run(driverName, nodeID, endpoint, volumeMounter, mountCacheDir, instanceID, pluginFolder string, cachePersister util.CachePersister) {
klog.Infof("Driver: %v version: %v", driverName, version)

// Configuration
PluginFolder = pluginFolder

if err := loadAvailableMounters(); err != nil {
klog.Fatalf("cephfs: failed to load ceph mounters: %v", err)
Expand Down
3 changes: 0 additions & 3 deletions pkg/rbd/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ type Driver struct {
var (
version = "1.0.0"

// PluginFolder defines the location of ceph plugin
PluginFolder = "/var/lib/kubelet/plugins/"

// CSIInstanceID is the instance ID that is unique to an instance of CSI, used when sharing
// ceph clusters across CSI instances, to differentiate omap names per CSI instance
CSIInstanceID = "default"
Expand Down
9 changes: 2 additions & 7 deletions pkg/util/cachepersister.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ import (
"k8s.io/klog"
)

const (
// PluginFolder defines location of plugins
PluginFolder = "/var/lib/kubelet/plugins"
)

// ForAllFunc is a unary predicate for visiting all cache entries
// matching the `pattern' in CachePersister's ForAll function.
type ForAllFunc func(identifier string) error
Expand All @@ -45,7 +40,7 @@ type CachePersister interface {
}

// NewCachePersister returns CachePersister based on store
func NewCachePersister(metadataStore, driverName string) (CachePersister, error) {
func NewCachePersister(metadataStore, pluginFolder string) (CachePersister, error) {
if metadataStore == "k8s_configmap" {
klog.Infof("cache-perister: using kubernetes configmap as metadata cache persister")
k8scm := &K8sCMCache{}
Expand All @@ -55,7 +50,7 @@ func NewCachePersister(metadataStore, driverName string) (CachePersister, error)
} else if metadataStore == "node" {
klog.Infof("cache-persister: using node as metadata cache persister")
nc := &NodeCache{}
nc.BasePath = PluginFolder + "/" + driverName
nc.BasePath = pluginFolder
nc.CacheDir = "controller"
return nc, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func roundUpSize(volumeSizeBytes, allocationUnitBytes int64) int64 {
}

// CreatePersistanceStorage creates storage path and initializes new cache
func CreatePersistanceStorage(sPath, metaDataStore, driverName string) (CachePersister, error) {
func CreatePersistanceStorage(sPath, metaDataStore, pluginPath string) (CachePersister, error) {
var err error
if err = createPersistentStorage(path.Join(sPath, "controller")); err != nil {
klog.Errorf("failed to create persistent storage for controller: %v", err)
Expand All @@ -60,7 +60,7 @@ func CreatePersistanceStorage(sPath, metaDataStore, driverName string) (CachePer
return nil, err
}

cp, err := NewCachePersister(metaDataStore, driverName)
cp, err := NewCachePersister(metaDataStore, pluginPath)
if err != nil {
klog.Errorf("failed to define cache persistence method: %v", err)
return nil, err
Expand Down

0 comments on commit 9b24524

Please sign in to comment.