Skip to content

Commit

Permalink
cephfs: use conf.InstanceID instead of global variable
Browse files Browse the repository at this point in the history
RBD does not have a global CSIInstanceID variable anymore, there is no
need for CephFS to use one either.

Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic authored and mergify[bot] committed Aug 5, 2024
1 parent dfb48ba commit 130e8b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
17 changes: 4 additions & 13 deletions internal/cephfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ type Driver struct {
cas *csiaddons.CSIAddonsServer
}

// 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.
var CSIInstanceID = "default"

// NewDriver returns new ceph driver.
func NewDriver() *Driver {
return &Driver{}
Expand Down Expand Up @@ -105,11 +101,6 @@ func (fs *Driver) Run(conf *util.Config) {
log.FatalLogMsg("cephfs: failed to load ceph mounters: %v", err)
}

// Use passed in instance ID, if provided for omap suffix naming
if conf.InstanceID != "" {
CSIInstanceID = conf.InstanceID
}

// Use passed in radosNamespace, if provided for storing CSI specific objects and keys.
if conf.RadosNamespaceCephFS != "" {
fsutil.RadosNamespace = conf.RadosNamespaceCephFS
Expand All @@ -127,16 +118,16 @@ func (fs *Driver) Run(conf *util.Config) {
}

// Create an instance of the volume journal
store.VolJournal = journal.NewCSIVolumeJournalWithNamespace(CSIInstanceID, fsutil.RadosNamespace)
store.VolJournal = journal.NewCSIVolumeJournalWithNamespace(conf.InstanceID, fsutil.RadosNamespace)

store.SnapJournal = journal.NewCSISnapshotJournalWithNamespace(CSIInstanceID, fsutil.RadosNamespace)
store.SnapJournal = journal.NewCSISnapshotJournalWithNamespace(conf.InstanceID, fsutil.RadosNamespace)

store.VolumeGroupJournal = journal.NewCSIVolumeGroupJournalWithNamespace(
CSIInstanceID,
conf.InstanceID,
fsutil.RadosNamespace)
// Initialize default library driver

fs.cd = csicommon.NewCSIDriver(conf.DriverName, util.DriverVersion, conf.NodeID)
fs.cd = csicommon.NewCSIDriver(conf.DriverName, util.DriverVersion, conf.NodeID, conf.InstanceID)
if fs.cd == nil {
log.FatalLogMsg("failed to initialize CSI driver")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cephfs/groupcontrollerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestControllerServer_validateCreateVolumeGroupSnapshotRequest(t *testing.T)
t.Parallel()
cs := ControllerServer{
DefaultControllerServer: csicommon.NewDefaultControllerServer(
csicommon.NewCSIDriver("cephfs.csi.ceph.com", "1.0.0", "test")),
csicommon.NewCSIDriver("cephfs.csi.ceph.com", "1.0.0", "test", "default")),
}

type args struct {
Expand Down

0 comments on commit 130e8b4

Please sign in to comment.