@@ -131,6 +131,10 @@ type Config struct {
131
131
// of this Ceph volume
132
132
csiImageIDKey string
133
133
134
+ // CSI GroupName is per Ceph volume object omap, contains the group ID of
135
+ // this Ceph volume
136
+ csiGroupIDKey string
137
+
134
138
// CSI image-name key in per Ceph volume object map, containing RBD image-name
135
139
// of this Ceph volume
136
140
csiImageKey string
@@ -174,6 +178,7 @@ func NewCSIVolumeJournal(suffix string) *Config {
174
178
cephSnapSourceKey : "" ,
175
179
namespace : "" ,
176
180
csiImageIDKey : "csi.imageid" ,
181
+ csiGroupIDKey : "csi.groupid" ,
177
182
encryptKMSKey : "csi.volume.encryptKMS" ,
178
183
encryptionType : "csi.volume.encryptionType" ,
179
184
ownerKey : "csi.volume.owner" ,
@@ -686,6 +691,7 @@ type ImageAttributes struct {
686
691
EncryptionType util.EncryptionType // Type of encryption used, if image encrypted
687
692
Owner string // Contains the owner to be used in combination with KmsID (for some KMS)
688
693
ImageID string // Contains the image id
694
+ GroupID string // Contains the group id of the image
689
695
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
690
696
BackingSnapshotID string // ID of the snapshot on which the CephFS snapshot-backed volume is based
691
697
}
@@ -718,6 +724,7 @@ func (conn *Connection) GetImageAttributes(
718
724
cj .csiImageIDKey ,
719
725
cj .ownerKey ,
720
726
cj .backingSnapshotIDKey ,
727
+ cj .csiGroupIDKey ,
721
728
}
722
729
values , err := getOMapValues (
723
730
ctx , conn , pool , cj .namespace , cj .cephUUIDDirectoryPrefix + objectUUID ,
@@ -736,6 +743,7 @@ func (conn *Connection) GetImageAttributes(
736
743
imageAttributes .Owner = values [cj .ownerKey ]
737
744
imageAttributes .ImageID = values [cj .csiImageIDKey ]
738
745
imageAttributes .BackingSnapshotID = values [cj .backingSnapshotIDKey ]
746
+ imageAttributes .GroupID = values [cj .csiGroupIDKey ]
739
747
740
748
// image key was added at a later point, so not all volumes will have this
741
749
// key set when ceph-csi was upgraded
@@ -795,6 +803,16 @@ func (conn *Connection) StoreAttribute(ctx context.Context, pool, reservedUUID,
795
803
return nil
796
804
}
797
805
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
+
798
816
// FetchAttribute fetches an attribute (key) in omap.
799
817
func (conn * Connection ) FetchAttribute (ctx context.Context , pool , reservedUUID , attribute string ) (string , error ) {
800
818
key := conn .config .commonPrefix + attribute
0 commit comments