go-ceph icon indicating copy to clipboard operation
go-ceph copied to clipboard

rbd snapshot rollback: facing 'RBD image not found' while rollbacking

Open shaekhhasanshoron opened this issue 6 years ago • 6 comments

Hello, I am using ceph octopus v15.2.4. I have created a snapshot using "volumesnapshot"(apiVersion is snapshot.storage.k8s.io/v1beta1). I was trying to rollback the snapshot but every time I was facing this issue RBD image not found. Please can anyone help me with this.

This is my code for rollbacking. Here I got 'snapImageName' value from volumesnapshotcontent. The snapshot was created as a separate image in ceph, which is why I had to get the snapshot name from snapImage using 'GetParentInfo' command.

ioContext, _ := this.radosConn.OpenIOContext(pool)
snapImage := rbd.GetImage(ioContext, snapImageName)

parentPool := make([]byte, 128)
parentName := make([]byte, 128)
parentSnapname := make([]byte, 128)

err := snapImage.GetParentInfo(parentPool, parentName, parentSnapname)
if err != nil {
	return err
}

n := bytes.Index(parentSnapname, []byte{0})
snapname := string(parentSnapname[:n])

image := rbd.GetImage(ioContext, image)
image, _ = rbd.OpenImage(ioContext, image, "")
snapshot := image.GetSnapshot(snapname)

err = snapshot.Rollback()
if err != nil {
  log.Println(err.Error())
}

shaekhhasanshoron avatar Sep 20 '20 20:09 shaekhhasanshoron

I only see one think at quick glance that seems odd to me and that's:

image := rbd.GetImage(ioContext, image)
image, _ = rbd.OpenImage(ioContext, image, "")

Where the 2nd line is immediately going to shadow the value that was fetched in the 1st. I'm not sure if that was intentional or not, or if it could be a problem or not. It just looks odd to me.

Without engaging deeper with your code snippet not much else jumps out at me but I know that @agarwal-mudit has been looking into this area recently and may have some thoughts.

I'll try to look deeper into this later myself, if needed.

phlogistonjohn avatar Sep 21 '20 13:09 phlogistonjohn

image, _ = rbd.OpenImage(ioContext, image, "")

I doubt if this returns a valid image. Can you get and pritnt the error returned by OpenImage() What is the second argunment of this function (it should be image name i.e. a string) but looks like you have passed "image" which you got from the line above that. This looks strange to me, as it should have resulted in compilation error.

Please note that GetImage() and GetSnapshot() do not do any validation, they just prepare and return the respective objects based on the passed names.

agarwal-mudit avatar Sep 21 '20 16:09 agarwal-mudit

@shaekhhasanshoron Also, are you sure that the flow is reaching the line where you are printing the error?

Because even GetParentInfo() should fail if the image is not opened.

agarwal-mudit avatar Sep 21 '20 16:09 agarwal-mudit

@shaekhhasanshoron please let us know if the replies helped you.

nixpanic avatar Oct 02 '20 13:10 nixpanic

@shaekhhasanshoron if you're still having issues or have additional questions please let us know. Otherwise we'll close this issue out in a week or two. Thanks!

phlogistonjohn avatar Oct 19 '20 14:10 phlogistonjohn

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contribution.

github-actions[bot] avatar Nov 19 '20 00:11 github-actions[bot]