journal: replace getStoredImageId with go-ceph

moved implementation of getStoredImageID to go-ceph
to get better performance.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2020-07-06 11:52:34 +05:30
committed by mergify[bot]
parent 341a3c9f59
commit 9bb79fbe7d
5 changed files with 14 additions and 22 deletions

View File

@ -124,12 +124,14 @@ type rbdSnapshot struct {
// RequestName is the CSI generated snapshot name for the rbdSnapshot
// JournalPool is the ceph pool in which the CSI snapshot Journal is stored
// Pool is where the image snapshot journal and snapshot is stored, and could be the same as `JournalPool`
// ImageID contains the image id of cloned image
SourceVolumeID string
RbdImageName string
ReservedID string
NamePrefix string
RbdSnapName string
SnapID string
ImageID string
Monitors string
JournalPool string
Pool string
@ -563,6 +565,7 @@ func genSnapFromSnapID(ctx context.Context, rbdSnap *rbdSnapshot, snapshotID str
if err != nil {
return err
}
rbdSnap.ImageID = imageAttributes.ImageID
rbdSnap.RequestName = imageAttributes.RequestName
rbdSnap.RbdImageName = imageAttributes.SourceName
rbdSnap.RbdSnapName = imageAttributes.ImageName
@ -633,6 +636,7 @@ func genVolFromVolID(ctx context.Context, volumeID string, cr *util.Credentials,
rbdVol.RequestName = imageAttributes.RequestName
rbdVol.RbdImageName = imageAttributes.ImageName
rbdVol.ReservedID = vi.ObjectUUID
rbdVol.ImageID = imageAttributes.ImageID
if imageAttributes.KmsID != "" {
rbdVol.Encrypted = true
@ -650,8 +654,7 @@ func genVolFromVolID(ctx context.Context, volumeID string, cr *util.Credentials,
}
}
rbdVol.ImageID, err = j.GetStoredImageID(ctx, rbdVol.JournalPool, rbdVol.ReservedID, cr)
if _, ok := err.(util.ErrKeyNotFound); ok {
if rbdVol.ImageID == "" {
err = rbdVol.getImageID()
if err != nil {
klog.Errorf(util.Log(ctx, "failed to get image id %s: %v"), rbdVol, err)