mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
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 <madhupr007@gmail.com>
This commit is contained in:
parent
4a463533ab
commit
95733b3a91
@ -131,6 +131,10 @@ type Config struct {
|
|||||||
// of this Ceph volume
|
// of this Ceph volume
|
||||||
csiImageIDKey string
|
csiImageIDKey string
|
||||||
|
|
||||||
|
// CSI GroupName is per Ceph volume object omap, contains the group ID of
|
||||||
|
// this Ceph volume
|
||||||
|
csiGroupIDKey string
|
||||||
|
|
||||||
// CSI image-name key in per Ceph volume object map, containing RBD image-name
|
// CSI image-name key in per Ceph volume object map, containing RBD image-name
|
||||||
// of this Ceph volume
|
// of this Ceph volume
|
||||||
csiImageKey string
|
csiImageKey string
|
||||||
@ -174,6 +178,7 @@ func NewCSIVolumeJournal(suffix string) *Config {
|
|||||||
cephSnapSourceKey: "",
|
cephSnapSourceKey: "",
|
||||||
namespace: "",
|
namespace: "",
|
||||||
csiImageIDKey: "csi.imageid",
|
csiImageIDKey: "csi.imageid",
|
||||||
|
csiGroupIDKey: "csi.groupid",
|
||||||
encryptKMSKey: "csi.volume.encryptKMS",
|
encryptKMSKey: "csi.volume.encryptKMS",
|
||||||
encryptionType: "csi.volume.encryptionType",
|
encryptionType: "csi.volume.encryptionType",
|
||||||
ownerKey: "csi.volume.owner",
|
ownerKey: "csi.volume.owner",
|
||||||
@ -686,6 +691,7 @@ type ImageAttributes struct {
|
|||||||
EncryptionType util.EncryptionType // Type of encryption used, if image encrypted
|
EncryptionType util.EncryptionType // Type of encryption used, if image encrypted
|
||||||
Owner string // Contains the owner to be used in combination with KmsID (for some KMS)
|
Owner string // Contains the owner to be used in combination with KmsID (for some KMS)
|
||||||
ImageID string // Contains the image id
|
ImageID string // Contains the image id
|
||||||
|
GroupID string // Contains the group id of the image
|
||||||
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
|
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
|
||||||
BackingSnapshotID string // ID of the snapshot on which the CephFS snapshot-backed volume is based
|
BackingSnapshotID string // ID of the snapshot on which the CephFS snapshot-backed volume is based
|
||||||
}
|
}
|
||||||
@ -718,6 +724,7 @@ func (conn *Connection) GetImageAttributes(
|
|||||||
cj.csiImageIDKey,
|
cj.csiImageIDKey,
|
||||||
cj.ownerKey,
|
cj.ownerKey,
|
||||||
cj.backingSnapshotIDKey,
|
cj.backingSnapshotIDKey,
|
||||||
|
cj.csiGroupIDKey,
|
||||||
}
|
}
|
||||||
values, err := getOMapValues(
|
values, err := getOMapValues(
|
||||||
ctx, conn, pool, cj.namespace, cj.cephUUIDDirectoryPrefix+objectUUID,
|
ctx, conn, pool, cj.namespace, cj.cephUUIDDirectoryPrefix+objectUUID,
|
||||||
@ -736,6 +743,7 @@ func (conn *Connection) GetImageAttributes(
|
|||||||
imageAttributes.Owner = values[cj.ownerKey]
|
imageAttributes.Owner = values[cj.ownerKey]
|
||||||
imageAttributes.ImageID = values[cj.csiImageIDKey]
|
imageAttributes.ImageID = values[cj.csiImageIDKey]
|
||||||
imageAttributes.BackingSnapshotID = values[cj.backingSnapshotIDKey]
|
imageAttributes.BackingSnapshotID = values[cj.backingSnapshotIDKey]
|
||||||
|
imageAttributes.GroupID = values[cj.csiGroupIDKey]
|
||||||
|
|
||||||
// image key was added at a later point, so not all volumes will have this
|
// image key was added at a later point, so not all volumes will have this
|
||||||
// key set when ceph-csi was upgraded
|
// key set when ceph-csi was upgraded
|
||||||
@ -795,6 +803,16 @@ func (conn *Connection) StoreAttribute(ctx context.Context, pool, reservedUUID,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StoreGroupID stores an groupID in omap.
|
||||||
|
func (conn *Connection) StoreGroupID(ctx context.Context, pool, reservedUUID, groupID string) error {
|
||||||
|
err := conn.StoreAttribute(ctx, pool, reservedUUID, conn.config.csiGroupIDKey, groupID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to store groupID %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// FetchAttribute fetches an attribute (key) in omap.
|
// FetchAttribute fetches an attribute (key) in omap.
|
||||||
func (conn *Connection) FetchAttribute(ctx context.Context, pool, reservedUUID, attribute string) (string, error) {
|
func (conn *Connection) FetchAttribute(ctx context.Context, pool, reservedUUID, attribute string) (string, error) {
|
||||||
key := conn.config.commonPrefix + attribute
|
key := conn.config.commonPrefix + attribute
|
||||||
|
Loading…
Reference in New Issue
Block a user