mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
journal: added csi.volume.backingsnapshotid image attribute
Signed-off-by: Robert Vasek <robert.vasek@cern.ch>
This commit is contained in:
committed by
mergify[bot]
parent
f7a9558728
commit
0807fd2e6c
@ -152,6 +152,9 @@ type Config struct {
|
||||
// ownerKey is used to identify the owner of the volume, can be used with some KMS configurations
|
||||
ownerKey string
|
||||
|
||||
// backingSnapshotIDKey is snapshot ID on which a shallow CephFS volume is based.
|
||||
backingSnapshotIDKey string
|
||||
|
||||
// commonPrefix is the prefix common to all omap keys for this Config
|
||||
commonPrefix string
|
||||
}
|
||||
@ -170,6 +173,7 @@ func NewCSIVolumeJournal(suffix string) *Config {
|
||||
csiImageIDKey: "csi.imageid",
|
||||
encryptKMSKey: "csi.volume.encryptKMS",
|
||||
ownerKey: "csi.volume.owner",
|
||||
backingSnapshotIDKey: "csi.volume.backingsnapshotid",
|
||||
commonPrefix: "csi.",
|
||||
}
|
||||
}
|
||||
@ -528,6 +532,7 @@ Input arguments:
|
||||
- kmsConf: Name of the key management service used to encrypt the image (optional)
|
||||
- volUUID: UUID need to be reserved instead of auto-generating one (this is useful for mirroring and metro-DR)
|
||||
- owner: the owner of the volume (optional)
|
||||
- backingSnapshotID: (optional)
|
||||
|
||||
Return values:
|
||||
- string: Contains the UUID that was reserved for the passed in reqName
|
||||
@ -537,7 +542,8 @@ Return values:
|
||||
func (conn *Connection) ReserveName(ctx context.Context,
|
||||
journalPool string, journalPoolID int64,
|
||||
imagePool string, imagePoolID int64,
|
||||
reqName, namePrefix, parentName, kmsConf, volUUID, owner string,
|
||||
reqName, namePrefix, parentName, kmsConf, volUUID, owner,
|
||||
backingSnapshotID string,
|
||||
) (string, string, error) {
|
||||
// TODO: Take in-arg as ImageAttributes?
|
||||
var (
|
||||
@ -639,6 +645,11 @@ func (conn *Connection) ReserveName(ctx context.Context,
|
||||
omapValues[cj.cephSnapSourceKey] = parentName
|
||||
}
|
||||
|
||||
// Update backing snapshot ID for shallow CephFS volume
|
||||
if backingSnapshotID != "" {
|
||||
omapValues[cj.backingSnapshotIDKey] = backingSnapshotID
|
||||
}
|
||||
|
||||
err = setOMapKeys(ctx, conn, journalPool, cj.namespace, oid, omapValues)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
@ -649,13 +660,14 @@ func (conn *Connection) ReserveName(ctx context.Context,
|
||||
|
||||
// ImageAttributes contains all CSI stored image attributes, typically as OMap keys.
|
||||
type ImageAttributes struct {
|
||||
RequestName string // Contains the request name for the passed in UUID
|
||||
SourceName string // Contains the parent image name for the passed in UUID, if it is a snapshot
|
||||
ImageName string // Contains the image or subvolume name for the passed in UUID
|
||||
KmsID string // Contains encryption KMS, if it is an encrypted image
|
||||
Owner string // Contains the owner to be used in combination with KmsID (for some KMS)
|
||||
ImageID string // Contains the image id
|
||||
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
|
||||
RequestName string // Contains the request name for the passed in UUID
|
||||
SourceName string // Contains the parent image name for the passed in UUID, if it is a snapshot
|
||||
ImageName string // Contains the image or subvolume name for the passed in UUID
|
||||
KmsID string // Contains encryption KMS, if it is an encrypted image
|
||||
Owner string // Contains the owner to be used in combination with KmsID (for some KMS)
|
||||
ImageID string // Contains the image id
|
||||
JournalPoolID int64 // Pool ID of the CSI journal pool, stored in big endian format (on-disk data)
|
||||
BackingSnapshotID string // ID of the backing snapshot of a shallow CephFS volume
|
||||
}
|
||||
|
||||
// GetImageAttributes fetches all keys and their values, from a UUID directory, returning ImageAttributes structure.
|
||||
@ -684,6 +696,7 @@ func (conn *Connection) GetImageAttributes(
|
||||
cj.cephSnapSourceKey,
|
||||
cj.csiImageIDKey,
|
||||
cj.ownerKey,
|
||||
cj.backingSnapshotIDKey,
|
||||
}
|
||||
values, err := getOMapValues(
|
||||
ctx, conn, pool, cj.namespace, cj.cephUUIDDirectoryPrefix+objectUUID,
|
||||
@ -700,6 +713,7 @@ func (conn *Connection) GetImageAttributes(
|
||||
imageAttributes.KmsID = values[cj.encryptKMSKey]
|
||||
imageAttributes.Owner = values[cj.ownerKey]
|
||||
imageAttributes.ImageID = values[cj.csiImageIDKey]
|
||||
imageAttributes.BackingSnapshotID = values[cj.backingSnapshotIDKey]
|
||||
|
||||
// image key was added at a later point, so not all volumes will have this
|
||||
// key set when ceph-csi was upgraded
|
||||
|
Reference in New Issue
Block a user