rbd: replace go-ceph GetParentInfo() with GetParent()

GetParent() is a newer and better version of
GetParentInfo() in go-ceph.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
This commit is contained in:
Mudit Agarwal 2020-11-02 17:25:41 +05:30 committed by mergify[bot]
parent eefaf09ade
commit 0ecfd0e72c

View File

@ -517,15 +517,11 @@ func (rv *rbdVolume) getParentName() (string, error) {
} }
defer rbdImage.Close() defer rbdImage.Close()
parentPool := make([]byte, 128) parentInfo, err := rbdImage.GetParent()
parentName := make([]byte, 128)
parentSnapname := make([]byte, 128)
err = rbdImage.GetParentInfo(parentPool, parentName, parentSnapname)
if err != nil { if err != nil {
return "", err return "", err
} }
return string(parentName), nil return parentInfo.Image.ImageName, nil
} }
func (rv *rbdVolume) flatten() error { func (rv *rbdVolume) flatten() error {
@ -941,22 +937,17 @@ func (rv *rbdVolume) getImageInfo() error {
rv.imageFeatureSet = librbd.FeatureSet(features) rv.imageFeatureSet = librbd.FeatureSet(features)
// Get parent information. // Get parent information.
// TODO: Replace GetParentInfo() after parentInfo, err := image.GetParent()
// https://github.com/ceph/go-ceph/issues/347 is fixed.
parentPool := make([]byte, 128)
parentName := make([]byte, 128)
parentSnapname := make([]byte, 128)
err = image.GetParentInfo(parentPool, parentName, parentSnapname)
if err != nil { if err != nil {
// Caller should decide whether not finding // Caller should decide whether not finding
// the parent is an error or not. // the parent is an error or not.
if strings.Contains(err.Error(), "No such file or directory") { if errors.Is(err, librbd.ErrNotFound) {
rv.ParentName = "" rv.ParentName = ""
} else { } else {
return err return err
} }
} else { } else {
rv.ParentName = string(parentName) rv.ParentName = parentInfo.Image.ImageName
} }
// Get image creation time // Get image creation time
tm, err := image.GetCreateTimestamp() tm, err := image.GetCreateTimestamp()