Skip to content

Commit 95733b3

Browse files
Madhu-1mergify[bot]
authored andcommitted
journal: add option to store the groupID
we need to have groupID stored and retrived when we are doing group level operations, we need to find out the groupID from the volumeID Signed-off-by: Madhu Rajanna <[email protected]>
1 parent 4a46353 commit 95733b3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

internal/journal/voljournal.go

+18
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ type Config struct {
131131
// of this Ceph volume
132132
csiImageIDKey string
133133

134+
// CSI GroupName is per Ceph volume object omap, contains the group ID of
135+
// this Ceph volume
136+
csiGroupIDKey string
137+
134138
// CSI image-name key in per Ceph volume object map, containing RBD image-name
135139
// of this Ceph volume
136140
csiImageKey string
@@ -174,6 +178,7 @@ func NewCSIVolumeJournal(suffix string) *Config {
174178
cephSnapSourceKey: "",
175179
namespace: "",
176180
csiImageIDKey: "csi.imageid",
181+
csiGroupIDKey: "csi.groupid",
177182
encryptKMSKey: "csi.volume.encryptKMS",
178183
encryptionType: "csi.volume.encryptionType",
179184
ownerKey: "csi.volume.owner",
@@ -686,6 +691,7 @@ type ImageAttributes struct {
686691
EncryptionType util.EncryptionType // Type of encryption used, if image encrypted
687692
Owner string // Contains the owner to be used in combination with KmsID (for some KMS)
688693
ImageID string // Contains the image id
694+
GroupID string // Contains the group id of the image
689695
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
690696
BackingSnapshotID string // ID of the snapshot on which the CephFS snapshot-backed volume is based
691697
}
@@ -718,6 +724,7 @@ func (conn *Connection) GetImageAttributes(
718724
cj.csiImageIDKey,
719725
cj.ownerKey,
720726
cj.backingSnapshotIDKey,
727+
cj.csiGroupIDKey,
721728
}
722729
values, err := getOMapValues(
723730
ctx, conn, pool, cj.namespace, cj.cephUUIDDirectoryPrefix+objectUUID,
@@ -736,6 +743,7 @@ func (conn *Connection) GetImageAttributes(
736743
imageAttributes.Owner = values[cj.ownerKey]
737744
imageAttributes.ImageID = values[cj.csiImageIDKey]
738745
imageAttributes.BackingSnapshotID = values[cj.backingSnapshotIDKey]
746+
imageAttributes.GroupID = values[cj.csiGroupIDKey]
739747

740748
// image key was added at a later point, so not all volumes will have this
741749
// key set when ceph-csi was upgraded
@@ -795,6 +803,16 @@ func (conn *Connection) StoreAttribute(ctx context.Context, pool, reservedUUID,
795803
return nil
796804
}
797805

806+
// StoreGroupID stores an groupID in omap.
807+
func (conn *Connection) StoreGroupID(ctx context.Context, pool, reservedUUID, groupID string) error {
808+
err := conn.StoreAttribute(ctx, pool, reservedUUID, conn.config.csiGroupIDKey, groupID)
809+
if err != nil {
810+
return fmt.Errorf("failed to store groupID %w", err)
811+
}
812+
813+
return nil
814+
}
815+
798816
// FetchAttribute fetches an attribute (key) in omap.
799817
func (conn *Connection) FetchAttribute(ctx context.Context, pool, reservedUUID, attribute string) (string, error) {
800818
key := conn.config.commonPrefix + attribute

0 commit comments

Comments
 (0)