From 130e8b42f2ef72bd54e8dc0f96823af3c3890ee8 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 5 Aug 2024 16:05:24 +0200 Subject: [PATCH] cephfs: use conf.InstanceID instead of global variable 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 --- internal/cephfs/driver.go | 17 ++++------------- internal/cephfs/groupcontrollerserver_test.go | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/internal/cephfs/driver.go b/internal/cephfs/driver.go index 162b027ee..97509956d 100644 --- a/internal/cephfs/driver.go +++ b/internal/cephfs/driver.go @@ -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{} @@ -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 @@ -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") } diff --git a/internal/cephfs/groupcontrollerserver_test.go b/internal/cephfs/groupcontrollerserver_test.go index 6aacc223b..a505064c7 100644 --- a/internal/cephfs/groupcontrollerserver_test.go +++ b/internal/cephfs/groupcontrollerserver_test.go @@ -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 {