From f091374ba9eb03d53d51a777f2803abb6c83f1b6 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Tue, 12 May 2020 09:22:07 -0400 Subject: [PATCH] journal: remove SetNamespace setter function The SetNamespace setter function was called only once, immediately after the creation of a volume journal object in cephfs only. Remove this function so that it is no longer implied that this field can be mutated after the journal is created. In it's place, use an extended "constructor" NewCSIVolumeJournalWithNamespace that takes a namespace value at create-time only. Signed-off-by: John Mulligan --- internal/cephfs/driver.go | 5 +---- internal/journal/voljournal.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/cephfs/driver.go b/internal/cephfs/driver.go index 40fcefed7..ccc4d6223 100644 --- a/internal/cephfs/driver.go +++ b/internal/cephfs/driver.go @@ -110,11 +110,8 @@ func (fs *Driver) Run(conf *util.Config, cachePersister util.CachePersister) { CSIInstanceID = conf.InstanceID } // Create an instance of the volume journal - volJournal = journal.NewCSIVolumeJournal(CSIInstanceID) + volJournal = journal.NewCSIVolumeJournalWithNamespace(CSIInstanceID, radosNamespace) - // Update namespace for storing keys into a specific namespace on RADOS, in the CephFS - // metadata pool - volJournal.SetNamespace(radosNamespace) // Initialize default library driver fs.cd = csicommon.NewCSIDriver(conf.DriverName, util.DriverVersion, conf.NodeID) diff --git a/internal/journal/voljournal.go b/internal/journal/voljournal.go index d50aa530a..3c530fc6e 100644 --- a/internal/journal/voljournal.go +++ b/internal/journal/voljournal.go @@ -176,6 +176,14 @@ func NewCSISnapshotJournal(suffix string) *CSIJournal { } } +// NewCSIVolumeJournalWithNamespace returns an instance of CSIJournal for +// volumes using a predetermined namespace value. +func NewCSIVolumeJournalWithNamespace(suffix, ns string) *CSIJournal { + j := NewCSIVolumeJournal(suffix) + j.namespace = ns + return j +} + // GetNameForUUID returns volume name func (cj *CSIJournal) GetNameForUUID(prefix, uid string, isSnapshot bool) string { if prefix == "" { @@ -188,11 +196,6 @@ func (cj *CSIJournal) GetNameForUUID(prefix, uid string, isSnapshot bool) string return prefix + uid } -// SetNamespace sets the namespace in which all RADOS objects would be created -func (cj *CSIJournal) SetNamespace(ns string) { - cj.namespace = ns -} - // ImageData contains image name and stored CSI properties type ImageData struct { ImageUUID string